Non-abstract class exception thrown for anonymous class declaration

View: New views
2 Messages — Rating Filter:   Alert me  

Non-abstract class exception thrown for anonymous class declaration

by Jeff Kolesky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to compile the following code snippet:

     return new FixedWidthDataReaderConfig() {
         { // instance initialization
             base(0);
             field("accountName").startsAt(0).length(30);
             field("account").startsAt(31).length(15);
         }
     };

The FixedWidthDataReaderConfig class implements the DataReaderConfig  
interface which has one method:

     DataReader getDataReader();

I compile the snippet like so:

     ScriptEvaluator evaluator = new ScriptEvaluator();
     evaluator.setDefaultImports(DEFAULT_IMPORTS);
     evaluator.setReturnType(DataReaderConfig.class);
     evaluator.cook(snippet);
     DataReaderConfig config = (DataReaderConfig)evaluator.evaluate
(null);

And I get this exception:

org.codehaus.janino.CompileException: Line 1, Column 41: Non-abstract  
class "SC$1" must implement method "poseur.di.io.DataReader  
poseur.di.io.config.DataReaderConfig.getDataReader()"
        at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java)
        at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java)

This only started happening after the fix for JANINO-95 went in.  The  
odd thing is that the anonymous class does actually implement the  
required method, since it is a subclass of a class that implements  
the method.  This code compiles fine using javac.

Is this a new bug in Janino or just such an odd case that I should  
figure out a way to work around it?

Thanks.

Jeff

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


Re: Non-abstract class exception thrown for anonymous class declaration

by Arno Unkrig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jeff,

I cannot quickly reproduce your problem. Can you please develop a
reduced scenario that reproduces it and submit a JIRA bug?


CU

Arno

Jeff Kolesky schrieb:

> I am trying to compile the following code snippet:
>
>     return new FixedWidthDataReaderConfig() {
>         { // instance initialization
>             base(0);
>             field("accountName").startsAt(0).length(30);
>             field("account").startsAt(31).length(15);
>         }
>     };
>
> The FixedWidthDataReaderConfig class implements the DataReaderConfig
> interface which has one method:
>
>     DataReader getDataReader();
>
> I compile the snippet like so:
>
>     ScriptEvaluator evaluator = new ScriptEvaluator();
>     evaluator.setDefaultImports(DEFAULT_IMPORTS);
>     evaluator.setReturnType(DataReaderConfig.class);
>     evaluator.cook(snippet);
>     DataReaderConfig config = (DataReaderConfig)evaluator.evaluate(null);
>
> And I get this exception:
>
> org.codehaus.janino.CompileException: Line 1, Column 41: Non-abstract
> class "SC$1" must implement method "poseur.di.io.DataReader
> poseur.di.io.config.DataReaderConfig.getDataReader()"
>     at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java)
>     at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java)
>
> This only started happening after the fix for JANINO-95 went in.  The
> odd thing is that the anonymous class does actually implement the
> required method, since it is a subclass of a class that implements the
> method.  This code compiles fine using javac.
>
> Is this a new bug in Janino or just such an odd case that I should
> figure out a way to work around it?
>
> Thanks.
>
> Jeff
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email