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

class extends and class implements sometimes written after anonymous class #93

Closed
slarse opened this issue Mar 30, 2020 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@slarse
Copy link
Collaborator

slarse commented Mar 30, 2020

Not sure what the problem is here, but sometimes an anonymous class that should look like this:

new SomeClass() {
    // implementation
}

instead looks like this:

new SomeClass()class  extends {
    // implementation
}

Obviously, this isn't even syntactically correct.

@slarse slarse added the bug Something isn't working label Mar 30, 2020
@slarse
Copy link
Collaborator Author

slarse commented Mar 30, 2020

Most likely, this is caused by this commit: e88f2c3, which resolves all anonymous class names to the empty string.

In combination with the fact that CtClass checks if it's anonymous by trying to parse its name to a number.

	@Override
	public boolean isAnonymous() {
		try {
			Integer.parseInt(getSimpleName());
		} catch (NumberFormatException e) {
			return false;
		}
		return true;
	}

This leads to anonymous classes not being identified as anonymous.

@slarse slarse closed this as completed in d4a42b4 Mar 30, 2020
@slarse
Copy link
Collaborator Author

slarse commented Mar 30, 2020

See #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant