pf » Null Java References in CF 6 vs 7
Null Java References in CF 6 vs 7

ColdFusion 7 appears to be much better at passing null values to a java object. ColdFusion 6 however likes to block you from doing it, even when you want to.
I am tring to work with a java API that requires me to pass a null value to a method. Since CFMX 6 has no way of creating a null value I though I would use the Java API to concoct one. So I did something like this:
vector = CreateObject("java", "java.util.Vector");
vector.setSize(1);
someAPI.methodThatRequiresANull(vector.get(0));
This works on ColdFusion 7, but on ColdFusion 6 it throws an exception:
The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
Null Pointers are another name for undefined values.
This trick isn't really useful because in ColdFusion 7 you can create a null value by calling JavaCast and using "null" as the type.
For example:
someAPI.methodThatRequiresANull( JavaCast("null", "") );
Does anyone know of a way to pass nulls that works in CF 6? I know I could just write some java, but I want the solution to be pure CFML in this case.
add to del.icio.us
| Tags: java, null, cfobject, createobject, coldfusion, cfml
Related Entries
- Serializing CFC's in ColdFusion 8 - August 6, 2007
- What's New in BlueDragon 7? - September 28, 2006
- DNS Query with ColdFusion - October 27, 2005
- Thread Priority, and Yielding - April 6, 2005
- Checking your JDBC Driver Version - March 31, 2004
I haven't tested yet, but I would think a generic one like this would work for all object types CreateObject('java', 'java.lang.Object').
- ColdFusion 8 FCKeditor Vulnerability
- Ajax Same Origin Policy No More with Firefox 3.5
- Firefox 3.5 Introduces Origin Header, Security Features
- Tips for Secure File Uploads with ColdFusion
- 7 Years And Blog Entry Number 700
- CFCatch Java Exceptions
- Cheat Sheet for SQL Server
- CFML on Google App Engine for Java
RSS

Pete Freitag is a software engineer, and web developer located in










