| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (Groovy3426Bug.groovy)

This example Groovy source code file (Groovy3426Bug.groovy) is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

class, groovy3426bug, groovy3426classproxymetaclass, groovy3426classproxymetaclass, groovy3426foo, groovy3426foo, groovytestcase, metaclass, metaclass, metaclassregistry, object, object, proxymetaclass, string

The Groovy Groovy3426Bug.groovy source code

package groovy.bugs

class Groovy3426Bug extends GroovyTestCase {

    MetaClassRegistry registry
    MetaClass originalMetaClass

    void setUp() {
        registry = GroovySystem.metaClassRegistry
        originalMetaClass = registry.getMetaClass(Groovy3426Foo)

    void tearDown() {
        registry.setMetaClass(Groovy3426Foo, originalMetaClass)

    void testCallSiteShouldBeUpdatedAfterOriginalMetaClassIsRestored() {
        def getFoo = { -> Groovy3426Foo.get() }

        MetaClass mc = new Groovy3426ClassProxyMetaClass(registry, Groovy3426Foo, originalMetaClass)
        registry.setMetaClass(Groovy3426Foo, mc)

        assert 'static' == Groovy3426Foo.get()
        assert 'static' == getFoo()

        registry.setMetaClass(Groovy3426Foo, originalMetaClass)

        assert 'foo' == Groovy3426Foo.get()
        assert 'foo' == getFoo()


class Groovy3426Foo {
    static get() { 'foo' }

class Groovy3426ClassProxyMetaClass extends ProxyMetaClass {
    Groovy3426ClassProxyMetaClass(MetaClassRegistry metaClassRegistry, Class aClass, MetaClass adaptee) {
        super(metaClassRegistry, aClass, adaptee)
    public Object invokeStaticMethod(final Object aClass, final String method, final Object[] arguments) {

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Groovy3426Bug.groovy source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.