+= Operator throws java.lang.IncompatibileClassChange errors after using duplicate()

Description

When using duplicate() on certain Java types (in this case, a MongoDB BasicDBObject), an IncompatibleClassChange error is thrown when using the += mathematical operator after using duplicate() on the object. The following error can be recreated with a com.mongodb.BasicDBObject - or any of the Mongo document objects - but likely affects other java classes as well:

//You'll need to have the mongo driver in the classpath to create the object below var response1 = createObject("java","com.mongodb.BasicDBObject"); response1['aNumber'] = 77; //duplicate() returns lucee.runtime.type.wrap.MapAsStruct //Note: structCopy() does not fail and will still return a BasicDBObject type var response = duplicate(response1); var countUp = 1; //Will throw error: java.lang.IncompatibleClassChangeError response['aNumber'] += countUp;

As noted above, the same error doesn't appear when using structCopy() instead of duplicate(), as the former returns the same class,where duplicate() returns a lucee.runtime.type.wrap.MapAsStruct object.

This error is not thrown in Lucee 4.2 (I haven't checked 4.3)

Environment

Version Lucee 4.5.3.000 final
Version Name Neo
Release date Nov 12, 2015
ColdFusion® compatibilty version 10.0.0.0
Configuration File /Users/jonclausen/.Commandbox/engine/cfml/server/lucee-server/context/lucee-server.xml
OS Mac OS X (10.11.1) 64bit
Remote IP 127.0.0.1
Host Name 127.0.0.1
Servlet Container Undertow - 1.3.0.Final (commandbox)
Java 1.7.0_45 (Oracle Corporation) 64bit
Architecture 64bit

Activity

Show:

Pothys - MitrahSoft 28 May 2020 at 10:40

I've checked this ticket with lucee latest version 5.3.7.34-SNAPSHOT also. Yes, the same issue has occurred while using + operator.

Alexander Kwaschny 28 May 2020 at 00:41

This problem applies to all Map implementations and still exists in 5.3.5.92. Math operator doesn’t matter.

<cfscript>     map = createObject("java", "java.util.LinkedHashMap").init();     map["foo"] = 0;     map["foo"] += 1;     // throws java.lang.IncompatibleClassChangeError     map["foo"]++;     // throws java.lang.IncompatibleClassChangeError: Class java.util.LinkedHashMap does not implement the requested interface lucee.runtime.type.Collection </cfscript>

Stacktrace points to

lucee.runtime.op.Operator.unaryPrPl(Operator.java:1144)

Needless to say it works in all versions of ACF.

Michael Offner 25 January 2016 at 19:14

"structCopy" and "duplicate" use the same functionality, the only difference is that "duplicate" does "deepCopy==true" and "structCopy" "deepCopy==false"

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 5 December 2015 at 01:05
Updated 19 May 2021 at 11:08

Flag notifications