Skip to content

Double datatype is used within switch-case statement in generated java source #21

Open
@denmase

Description

@denmase

Hi @vruusmann,

While testing for your release after #20, I tried to transpile a folder which contains many pmml files, and accidentally, one of them was from Extending Scikit-Learn with CHAID model type, and it was the only file which wasn't compiled properly with following error:

Transpiling: CHAIDIris.pmml
META-INF/services\org.dmg.pmml.PMML
com\mycompany\MyModel.java
com\mycompany\PMML$1041109062.data
/com/mycompany/MyModel.java:188: error: incompatible types: java.lang.Double cannot be converted to int
/com/mycompany/MyModel.java:293: error: incompatible types: java.lang.Double cannot be converted to int
 ==> FAILED.
java.io.IOException
	at org.jpmml.codemodel.CompilerUtil.compile(CompilerUtil.java:89)
	at org.jpmml.transpiler.TranspilerUtil.compile(TranspilerUtil.java:103)
	at org.jpmml.transpiler.TranspilerUtil.compile(TranspilerUtil.java:81)
	at com.mycompany.mavenproject1.Main.transpilePmml(Main.java:242)
	at com.mycompany.mavenproject1.Main.main(Main.java:130)

Lines 188 & 293 are both a switch-case statement

      Double javaValue = value.asDouble();
      switch (javaValue) { // <== this is line 188, 293

I don't know whether it is changed in Java 9 or later, but at least AFAIK in Java 8, we cannot use double in switch-case statement. Consider using if instead?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions