Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3788860
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:03:54+00:00 2026-05-19T12:03:54+00:00

I have configured a Maven build for a very small GWT project I’m having.

  • 0

I have configured a Maven build for a very small GWT project I’m having. Compiling/running from Eclipse causes no problem, but when I execute Maven build, I’ve got compilation issues in one single place (this is GWT ‘client-side’ code, but I’m not sure if that’s the case). Maven/compile output:

[..]SmartTable.java:[63,52] ')' expected
[..]SmartTable.java:[63,53] ')' expected
[..]SmartTable.java:[63,69] ';' expected
[..]SmartTable.java:[63,71] not a statement
[..]SmartTable.java:[63,77] ';' expected
[..]SmartTable.java:[63,79] not a statement

.. where this specific line defined as following:

final Comparator<T> comparator = ((SmartTable<T>.ComparableColumn) column).comparator;

As you have guessed, I’m iterating over all columns defined for this generics-class (which I call ‘SmartTable’), and getting a comparator (of course, if column instanceof SmartTable.ComparableColumn) for further operations.
Classes ‘Column’ and ‘ComparableColumn’ are nested in SmartTable, and their headers looks as following:

public abstract class Column {
    // private String id;
    private String caption;
    private int width;
    private Filter<T> filter;
...
public class ComparableColumn extends Column {
    private Comparator<T> comparator;
...

When it gets compiled from Eclipse, I have no problems in packaging WAR (without ‘clean’ – simply package which will work since Eclipse configured to place .class files in the same target directory used by Maven) and deploying/running it correctly.

I’ve already tried changing maven-compiler-plugin and configuration (setting values 1.5, 1.6; and 1.4 – for sake of experiment to see if it will start complain on generics in general), but that wasn’t of help. Eclipse project compiler compliance is default (1.6). It seems that I have no other compilation issues with the other generics code.

Tried to make it as short as possible, but not sure if I managed to do it well 🙂

EDIT: More of code by demand

public class SmartTable<T> extends FlexTable {
    private List<Column> columns = new ArrayList<Column>();
    ...
    private Comparator<T> currentComparator;
...

    public void init(Comparator<T> defaultComparator) {
        this.currentComparator = defaultComparator;
        ...
        int index = 0;
        for (Column column : columns) {
            ...
            if (column instanceof SmartTable.ComparableColumn) {
                @SuppressWarnings("unchecked")
                final Comparator<T> comparator = ((SmartTable<T>.ComparableColumn) column).comparator;
            ...
    }
...

    public abstract class Column {
        // private String id;
        private String caption;
        private int width;
        private Filter<T> filter;
        private List<WidgetCreator<T>> widgetCreators;

        public Column(/* String id, */String caption, int width, Filter<T> filter, List<WidgetCreator<T>> widgetCreators) {

...

    public class SimpleColumn extends Column {
        public SimpleColumn(/* String id, */String caption, int width, Filter<T> filter, List<WidgetCreator<T>> widgetCreators) {
            super(/* id, */caption, width, filter, widgetCreators);
        }

...

    public class ComparableColumn extends Column {
        private Comparator<T> comparator;

        public ComparableColumn(/* String id, */String caption, int width, Filter<T> filter,
                List<WidgetCreator<T>> widgetCreators, Comparator<T> comparator) {
            super(/* id, */caption, width, filter, widgetCreators);
            this.comparator = comparator;
        }

...

}

EDIT2: Actual problem seems to be very concentrated 🙂

public class SmartTable2<T> {
    public void init() {
        Column c = new ComparableColumn();

        final Comparator<T> comparator = ((SmartTable2<T>.ComparableColumn) c).comparator;
    }

    class Column {

    }

    class ComparableColumn extends Column {
        Comparator<T> comparator;
    }
}

EDIT3: Some thoughts, hopefully closer to the solution
.. so this doesn’t compile simply with javac, throwing exactly same compilation errors. So what I’ve learned just now: Eclipse uses it’s own internal Java compiler – which is part of JDT Core (hope I have not misunderstood it); so might it be the case that JDT Compiler is able to compile such a syntax, while Sun’s JDK javac is not??? (oops, Oracle not Sun)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:03:55+00:00Added an answer on May 19, 2026 at 12:03 pm

    Try this syntax:

    Comparator<T> comparator = (Comparator<T>) ((SmartTable.ComparableColumn) column).comparator;
    

    EDIT:
    The cast is useless:

    Comparator<T> comparator = ((SmartTable.ComparableColumn) column).comparator;
    

    Does this resemble your scenario ?

    public class Main {
    
        public static <T> void main(String[] args) throws Exception {
            SmartTable<T>.Column column = new SmartTable<T>().new Column();
            Comparator<T> comparator = ((SmartTable.ComparableColumn) column).comparator;
    
        }
    
        static class SmartTable<T> {
            class Column {
    
            }
            class ComparableColumn extends Column {
                Comparator<T> comparator;
            }
        }
    
    }
    

    This compiles fine with javac (with unchecked warnings, of course), while trying to compile the cast to (SmartTable.ComparableColumn) results in exactly the errors in your post.

    EDIT (of all edits):
    Your question seems to have been asked before: Casting to an inner class with generics and the answer seems to be a compiler bug: https://bugs.java.com/bugdatabase/view_bug?bug_id=6665356

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a maven-multi project, when I create a new eclipse project from it
how to run findbugs through eclipse with maven project. I have configured in maven
I have maven configured for my java project to build single jar with all
I am using Eclipse Helios and JBoss 4.2.0. I have built a maven project
I have successfully installed & configured the M2E Maven plugin for Eclipse, along with
I have a Maven (3.0.3) / GWT (2.4) project. I'm trying to write some
I have a Java multi-module Maven project that I want to build an MVN
I have a project with Maven build and need to add some basic performance
I have configured my Web.Config file as follow in a ASP.NET MVC 2 project:
I have flex application consisting of several modules which is configured using maven. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.