Skip to content

Java() does not detect anonymous inner classes when embedded in constructor argument #1658

Closed

Description

@bdbaddog

This issue was originally created at: 2007-05-11 00:53:45.
This issue was reported by: nijtmans.
nijtmans said at 2007-05-11 00:53:45

Below is an example. This example prints:
['Foo.class']
But it should print:
['Foo$1.class', 'Foo$2.class', 'Foo.class']

============= SConstruct =============
print Java('.', '.')
============= Foo.java ================
import java.io.File;

public class Foo {

public static void main(String[] args) {
File f = new File(
new File("a") {
public String toString() {
return "b";
}
}.toString()
) {
public String toString() {
return "c";
}
};
}
}

nijtmans said at 2007-05-23 02:07:04

Created an attachment (id=191)
proposed fix

nijtmans said at 2007-05-23 02:14:11

We were so stuck with this bug that we decided to develop a fix for this: It
was less work than introduce workarounds for it in our code.

This fix is tested on serveral thousends of real-life java files. Originally,
7 of them had anonimous internal classes which were undetected by the
parser, this implementation now detects all of them.

We did this by modifying AnonClassState allow it to handle round braces
as well, and also allowing it to call itself recursively. This handles
all situations we can think of.

stevenknight said at 2007-05-23 05:22:16

Fix integrated for next release. Many thanks for the fix, and for the
straightforward test case.

nijtmans attached fix1658.txt at 2007-05-23 02:07:04.

proposed fix

stevenknight said this issue blocks #1664 at 2007-05-23 05:22:16.

Activity

  1. added this to the 0.97.1 milestone on Jan 2, 2018
  2. added
    Java
    and removed on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaVersion: 0.96.96bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions