[YANGTOOLS-357] Binding Java API Generator -> ClassCastException thrown during code generation from specific yang models (casting ConcreteTypeImpl to GeneratedTransferObject) Created: 05/Nov/14  Updated: 10/Apr/22  Resolved: 10/Nov/14

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Martin Ciglan Assignee: Martin Ciglan
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Duplicate
duplicates MDSAL-2 Naming conflict appears when key of l... Resolved
External issue ID: 2324

 Description   

[ERROR] yang-to-sources: Unable to generate sources with org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl generator
java.lang.ClassCastException: org.opendaylight.yangtools.binding.generator.util.Types$ConcreteTypeImpl cannot be cast to org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject
at org.opendaylight.yangtools.sal.java.api.generator.BuilderTemplate.generateCopyConstructor(BuilderTemplate.java:1326)

.
.
.
.

Unhandled situation in BuilderTemplate.xtend, possible instanceof check missing before casting

«val keyProps = new ArrayList((keyType as GeneratedTransferObject).properties)»



 Comments   
Comment by Martin Ciglan [ 05/Nov/14 ]

fix pushed

https://git.opendaylight.org/gerrit/#/c/12525/

Comment by Martin Ciglan [ 07/Nov/14 ]

Based on discussion & findings, casting is valid, issue should be resolved before that.

Finding:
Per specific model given, getKey() method within generated BuilderTemplate class returns returnType = Type (java.lang.String), which is a Java concrete type. Therefore, ClassCastException is thrown.

In progress...

Generated at Wed Feb 07 20:52:59 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.