-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta2
-
generic
-
generic
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2041356 | 1.4.0 | Stefan Bauer | P3 | Closed | Won't Fix |
Name: krC82822 Date: 03/11/2001
java version "1.3.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
Java HotSpot(TM) Client VM (build 1.3.0_01, interpreted mode)
There are two related problems here.
1) There is a difference in behavior between ORB.create_value_tc and
ORBSingleton.create_value_tc, with respect to the concrete_base argument.
The latter tests for a null value and substitutes a tk_null TypeCode,
whereas the former does not. If you use ORB.create_value_tc and
pass a null value for concrete_base, a NullPointerException will
occur. To be compliant, the create_value_tc operation must accept
a null value for the concrete base type. Section 10.7.3 of CORBA 2.3
(OMG document 98-12-01) states:
"For create_value_tc operation, the concrete_base parameter is a TypeCode for
the immediate concrete valuetype base of the valuetype for which the TypeCode is
being created. If the valuetype does not have a concrete base, the concrete_base
parameter is a nil TypeCode reference."
2) Assuming that you managed to successfully create a valuetype with no
concrete base type, calling TypeCode.concrete_base_type() returns the
tk_null TypeCode. This is not compliant. Section 10.7.1 of CORBA 2.3
(OMG document 98-12-01) states:
"If the valuetype represented by the target TypeCode has a concrete base
valuetype, the concrete_base_type operation returns a TypeCode for the
concrete base, otherwise it returns a nil TypeCode reference."
To summarize, create_value_tc must accept a null value for the concrete
base argument, and concrete_base_type must return a null value when
appropriate.
These problems can be reproduced using this example:
public class TypeCodeBugs
{
private static void
usage()
{
System.out.println("Usage: TypeCodeBugs (full|singleton)");
System.exit(0);
}
public static void
main(String[] args)
{
try
{
if(args.length == 0)
usage();
org.omg.CORBA.ORB orb = null;
if(args[0].equals("full"))
orb = org.omg.CORBA.ORB.init(args, null);
else if(args[0].equals("singleton"))
orb = org.omg.CORBA.ORB.init();
else
usage();
org.omg.CORBA.TypeCode tc =
orb.create_value_tc("IDL:Foo:1.0", "Foo",
org.omg.CORBA.VM_NONE.value,
null, new org.omg.CORBA.ValueMember[0]);
org.omg.CORBA.TypeCode concreteBaseType = tc.concrete_base_type();
if(concreteBaseType == null)
System.out.println("This is the correct result");
else if(concreteBaseType.kind() == org.omg.CORBA.TCKind.tk_null)
System.out.println("This is the incorrect result");
}
catch(org.omg.CORBA.TypeCodePackage.BadKind ex)
{
ex.printStackTrace();
}
}
}
(Review ID: 118544)
======================================================================
Name: krC82822 Date: 03/20/2001
The problem happens with both Java 1.2.2 and Java 1.3.0 on both NT and Solaris.
JDK ORB.create_value_tc() throws a NullPointerException when the concrete base
parameter is passed a null. The problem happens with both applets and
applications. It is platform & JDK version independent (it happens on both NT
and Solaris, with both JDK1.2.2 and JDK1.3.0).
Here is a simple test case:
======== ResultObject.java =============
import java.util.*;
import java.io.*;
import java.text.*;
public class ResultObject implements Serializable
{
public ResultObject()
{
}
}
========= Tester.java ======================
public class Tester extends java.applet.Applet{
public void init() {
try {
System.out.println("Initializing ORB in main");
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(this,null);
org.omg.CORBA.TypeCode tc =
orb.create_value_tc("RMI:ResultObject:71DA8BE7F971128","ResultObject",(short)0,n
ull, new org.omg.CORBA.ValueMember[0]);
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String [] args) {
try {
System.out.println("Initializing ORB in main");
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
org.omg.CORBA.TypeCode tc =
orb.create_value_tc("RMI:ResultObject:71DA8BE7F971128","ResultObject",(short)0,n
ull, new org.omg.CORBA.ValueMember[0]);
} catch(Exception e) {
e.printStackTrace();
}
}
}
=================== tester.html =======================
Test Applet
<br>
open java console to see results
<applet archive="" code="Tester.class" width="400" height="30">
</applet>
Steps to reproduce:
1. compile the above two java files:
javac ResultObject.java Tester.java
2. run the application:
java Tester
and got the following exception stack trace:
Initializing ORB in main
java.lang.NullPointerException
at com.sun.CORBA.idl.TypeCodeImpl.<init>(TypeCodeImpl.java:492)
at com.sun.CORBA.idl.TypeCodeImpl.convertToNative(TypeCodeImpl.java:873)
at com.sun.CORBA.idl.TypeCodeImpl.<init>(TypeCodeImpl.java:688)
at com.sun.CORBA.idl.ORB.create_value_tc(ORB.java:1082)
at Tester.main(Tester.java:17)
3. run the applets with jdk1.2.2 or jdk1.3.0 appletviewer:
appletviewer http://<host>:<port>/tester.html
and got the following output:
Initializing ORB in main
java.lang.NullPointerException
at
com.sun.corba.se.internal.corba.TypeCodeImpl.<init>(TypeCodeImpl.java:495)
at
com.sun.corba.se.internal.corba.TypeCodeImpl.convertToNative(TypeCodeImpl.java:8
85)
at
com.sun.corba.se.internal.corba.TypeCodeImpl.<init>(TypeCodeImpl.java:690)
at com.sun.corba.se.internal.corba.ORB.create_value_tc(ORB.java:1303)
at Tester.init(Tester.java:7)
at sun.applet.AppletPanel.run(AppletPanel.java:344)
at java.lang.Thread.run(Thread.java:484)
(Review ID: 119133)
======================================================================
- backported by
-
JDK-2041356 Incorrect TypeCode behavior for valuetypes (CORBA 2.3 compliance issues)
-
- Closed
-
- duplicates
-
JDK-4431413 ORB.create_value_tc() throws NullPointerException when concrete base is null
-
- Closed
-