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

"unexpected token" on anonymous instance of parameterized Comparator #533

Closed
processing-bugs opened this Issue Feb 10, 2013 · 6 comments

Comments

Projects
None yet
3 participants
@processing-bugs

processing-bugs commented Feb 10, 2013

Original author: e.e.coli@gmail.com (December 24, 2010 15:22:22)

import java.util.*;

final Object q = new HashMap<String, Collection<Integer>>();

final Comparator<String> comparator = new Comparator<String>()
{
  public int compare(final String value0, final String value1)
  {
    return value0.compareTo(value1);
  }
};

List<String> s = Arrays.asList("g", "d", "z"); 
Collections.sort(s, comparator);
println(s);

Original issue: http://code.google.com/p/processing/issues/detail?id=494

@processing-bugs

This comment has been minimized.

Show comment
Hide comment
@processing-bugs

processing-bugs Feb 10, 2013

From e.e.coli@gmail.com on April 16, 2011 23:37:42
Hi, folks. I'm on vacation, so it will be at least a week before I can look into this.

processing-bugs commented Feb 10, 2013

From e.e.coli@gmail.com on April 16, 2011 23:37:42
Hi, folks. I'm on vacation, so it will be at least a week before I can look into this.

@processing-bugs

This comment has been minimized.

Show comment
Hide comment
@processing-bugs

processing-bugs Feb 10, 2013

From f...@processing.org on April 17, 2011 04:40:31
No worries, I was only adding myself as a CC since you'd filed this against yourself back in December and I just ran across it today.

processing-bugs commented Feb 10, 2013

From f...@processing.org on April 17, 2011 04:40:31
No worries, I was only adding myself as a CC since you'd filed this against yourself back in December and I just ran across it today.

@benfry benfry added the preprocessor label Jul 31, 2014

@benfry benfry removed the bug label Nov 15, 2014

@benfry benfry added the help wanted label Jun 16, 2015

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Aug 11, 2015

Contributor

This works:

import java.util.*;

void setup() {
  final Object q = new HashMap<String, Collection<Integer>>();

  final Comparator<String> comparator = new Comparator<String>() {
    public int compare(final String value0, final String value1) {
      return value0.compareTo(value1);
    }
  };

  List<String> s = Arrays.asList("g", "d", "z");
  Collections.sort(s, comparator);
  println(s);
}

This does not:

import java.util.*;

final Object q = new HashMap<String, Collection<Integer>>();

final Comparator<String> comparator = new Comparator<String>() {
  public int compare(final String value0, final String value1) {
    return value0.compareTo(value1);
  }
};

List<String> s = Arrays.asList("g", "d", "z");
Collections.sort(s, comparator); // error on "(", error on ",",
                                 // missing a semicolon, missing right curly bracket
println(s); // error on "... VariableDeclaratorId", error on "}"
Contributor

JakubValtar commented Aug 11, 2015

This works:

import java.util.*;

void setup() {
  final Object q = new HashMap<String, Collection<Integer>>();

  final Comparator<String> comparator = new Comparator<String>() {
    public int compare(final String value0, final String value1) {
      return value0.compareTo(value1);
    }
  };

  List<String> s = Arrays.asList("g", "d", "z");
  Collections.sort(s, comparator);
  println(s);
}

This does not:

import java.util.*;

final Object q = new HashMap<String, Collection<Integer>>();

final Comparator<String> comparator = new Comparator<String>() {
  public int compare(final String value0, final String value1) {
    return value0.compareTo(value1);
  }
};

List<String> s = Arrays.asList("g", "d", "z");
Collections.sort(s, comparator); // error on "(", error on ",",
                                 // missing a semicolon, missing right curly bracket
println(s); // error on "... VariableDeclaratorId", error on "}"

@JakubValtar JakubValtar added revised and removed revision needed labels Aug 11, 2015

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Aug 11, 2015

Member

Ah, so that's a little more fixable (rather than waiting for an ANTLR4 update). Can you look into his one?

Member

benfry commented Aug 11, 2015

Ah, so that's a little more fixable (rather than waiting for an ANTLR4 update). Can you look into his one?

@benfry benfry removed the low label Aug 11, 2015

@JakubValtar JakubValtar self-assigned this Aug 11, 2015

@benfry benfry added this to the 3.0 final milestone Aug 11, 2015

@benfry benfry removed the revised label Aug 11, 2015

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Sep 9, 2015

Member

Let's detect this based on whether a setup() or draw() method is found.

Member

benfry commented Sep 9, 2015

Let's detect this based on whether a setup() or draw() method is found.

JakubValtar added a commit to JakubValtar/processing that referenced this issue Sep 9, 2015

Allow anonymous classes in static mode
catch: if they have a method in their body named setup or draw, mode is
always (sometimes incorrectly) detected as Active

Fixes #533

@benfry benfry closed this in #3780 Sep 9, 2015

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Sep 9, 2015

Member

Fixed in 3.0 beta 6 by @JakubValtar

Member

benfry commented Sep 9, 2015

Fixed in 3.0 beta 6 by @JakubValtar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment