the number of constructors during runtime and compile time for java.math.BigDecimal do not match

i defined a new class called BigDecimalWithAttrDisplay with the following implementation:

class BigDecimalWithAttrDisplay extends BigDecimal{
    String display;
    BigDecimalWithAttrDisplay(String val){super(val)}
    public String toString(){
        "BigDecimalWithAttrDisplay{val=${super.toString()}, display='$display'}";

when trying to run code that use this class i get:

java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.math.BigDecimal do not match. Expected 17 but got 18
at groovy.lang.MetaClassImpl.selectConstructorAndTransformArguments(
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.selectConstructorAndTransformArguments(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at org.codehaus.groovy.reflection.CachedConstructor.invoke(
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(
at org.codehaus.groovy.runtime.callsite.ConstructorSite.callConstructor(
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(

what is the problem and how can i fix it?


Try cleaning your created classes (do a fresh rebuild of your project). You might have artifacts from previous compilations.

Another possibility would be that you use Java 7 and Groovy code compiled with a version lower than 7. Then you might also encounter problems. (See for example: Geb - IncompatibleClassChangeError)

Couldn't reproduce your bug in 2.0.5, but if the problem is the lack of constructors, Groovy has an annotation called @InheritConstructors which might help.

Also take a look at @Delegate. It might be cooler than inheritance.

Add a call to BigDecimal constructor by adding super(val) in your constructor.

Need Your Help

Cloud SQL database failed to connect from mysql client

mysql google-app-engine google-cloud-sql

I'm unable to connect to Google Cloud SQL from my desktop mysql client. I am also unable to set the sql instance password in google console. It says "instance is busy". I was able to connect to the...

Package Autoloading Issues

php package composer-php

I'm struggling to work out how to correctly build and autoload my first composer package. I understand that if I follow the PSR-0 naming convention, autoloading should "just work". I am trying to s...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.