Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Illegal Java code is transformed #6163

Open
Clipi-12 opened this issue Jan 28, 2025 · 0 comments
Open

[Bug]: Illegal Java code is transformed #6163

Clipi-12 opened this issue Jan 28, 2025 · 0 comments
Labels

Comments

@Clipi-12
Copy link

Clipi-12 commented Jan 28, 2025

Describe the bug

When entering illegal Java code, the result is usually transformed to a different (but still illegal) code. However, in some cases it get transformed / deleted.

Source code you are trying to analyze/transform

0;
0++;
int a = 0++;

MCVE

package my.spoon.code;

import spoon.Launcher;
import spoon.support.compiler.VirtualFile;

public class Main {
  public static void main(String[] args) {
      Launcher launcher = new Launcher();
      launcher.addInputResource(new VirtualFile(
        """
          package the.pkg.name;

          class ClassName {
            void methodName() {
              0;
              0++;
              int a = 0++;
            }
          }
        """
      ));
      System.out.println(launcher.buildModel().getAllTypes());
  }
}

Actual output

0 = the.pkg.name.$missing$; // <- `0;`
                            // <- `0++;`
int a = 0;                  // <- `int a = 0++;`

Expected output

// The same output. Illegal code shouldn't get transformed
0;
0++;
int a = 0++;

Spoon Version

11.2.0

JVM Version

17

What operating system are you using?

Windows 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant