Skip to content

Error when compiling Tooling API Java Bindings (enum constant value starting with the number) #334

Description

@bereg2k

Tooling API WSDL generates the XML file with the following element inside of it:

<xsd:simpleType name="CalculatedInsightPublishScheduleInterval">
<xsd:restriction base="xsd:string">
 <xsd:enumeration value="0"/>
 <xsd:enumeration value="1"/>
 <xsd:enumeration value="6"/>
 <xsd:enumeration value="12"/>
 <xsd:enumeration value="24"/>
</xsd:restriction>
</xsd:simpleType>

However, when compiling Java Bindings for the SOAP API for it, the execution fails:

Logs:

[WSC][ForkJoinWorkerThread.run:165]Generating Java files from schema ...
[WSC][ForkJoinWorkerThread.run:165]Generated 2474 java files.
Error at Line: 18, enum constant expected here in /var/folders/xj/19zsgqxd3_s66jm1st8xqvxm0000gn/T/wsc-scratch2673595683628563348tmp/com/sforce/soap/tooling/CalculatedInsightPublishScheduleInterval.java 
Error at Line: 61, <identifier> expected in /var/folders/xj/19zsgqxd3_s66jm1st8xqvxm0000gn/T/wsc-scratch2673595683628563348tmp/com/sforce/soap/tooling/CalculatedInsightPublishScheduleInterval.java 
Error: Failed to compile

This is the underlying Java class which the script is trying to create from the XML element:

CalculatedInsightPublishScheduleInterval.java

package com.sforce.soap.tooling;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * This is a generated class for the SObject Enterprise API.
 * Do not edit this file, as your changes will be lost.
 */
public enum CalculatedInsightPublishScheduleInterval {


  
        /**
         * Enumeration  : 0
         */
        0("0"),

  
        /**
         * Enumeration  : 1
         */
        1("1"),

  
        /**
         * Enumeration  : 6
         */
        6("6"),

  
        /**
         * Enumeration  : 12
         */
        12("12"),

  
        /**
         * Enumeration  : 24
         */
        24("24"),

;

        public static Map<String, String> valuesToEnums;

        static {
                valuesToEnums = new HashMap<String, String>();
                for (CalculatedInsightPublishScheduleInterval e : EnumSet.allOf(CalculatedInsightPublishScheduleInterval.class)) {
                        valuesToEnums.put(e.toString(), e.name());
                }
        }

        private String value;

        private CalculatedInsightPublishScheduleInterval(String value) {
                this.value = value;
        }

        @Override
        public String toString() {
                return value;
        }
}

Having enum values like this won't compile because it's incorrect Java syntax: 0("0"), 1("1")

Is it possible to work around this by compiling such enumerations using the _ symbol in the beginning?
Like this: _0("0"), _1("1")


Library version in Maven POM:

<dependency>
    <groupId>com.force.api</groupId>
    <artifactId>force-wsc</artifactId>
    <version>62.0.0</version>
</dependency>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions