forcedotcom / forcedotcom/wsc

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

Open
#334 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
276
Forks
223
PR merge metrics
No merged PRs in 30d

Description

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

```xml





```

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, 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**
```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 valuesToEnums;

static {
valuesToEnums = new HashMap();
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:

```xml

com.force.api
force-wsc
62.0.0

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the WSDL enumeration for CalculatedInsightPublishScheduleInterval and the generated CalculatedInsightPublishScheduleInterval.java shown in the report. Trace the Tooling API Java binding generation path that turns enumeration values into Java identifiers, then verify that numeric values produce valid bindings that compile without losing their original string values.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.