pombreda / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 1 forks source link

Line number issue under java 8 and guice 4.0 beta 4 #804

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Failure when trying to report injection errors when use of static methods on 
interface is present.

The failure comes from the line number stuff using ASM:

Exception in thread "main" 
com.google.common.util.concurrent.UncheckedExecutionException: 
java.lang.IllegalArgumentException: INVOKESPECIAL/STATIC on interfaces require 
ASM 5
       at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
       at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
       at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
       at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
       at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827)
       at com.google.inject.internal.util.StackTraceElements.forMember(StackTraceElements.java:66)
       at com.google.inject.internal.Errors.formatSource(Errors.java:764)
       at com.google.inject.internal.Errors.formatSource(Errors.java:743)
       at com.google.inject.internal.Errors.formatInjectionPoint(Errors.java:794)

Here is a standalone example to reproduce:

import com.google.inject.AbstractModule;
import com.google.inject.Guice;

public class Test
{
    public Test()
    {
        throw new RuntimeException("No chance");
    }

    void doStatic()
    {
        X.something();
    }

    interface X
    {
        static int something()
        {
            return 1;
        }
    }

    private static class TestModule extends AbstractModule
    {

        @Override
        protected void configure()
        {
            bind(Test.class).asEagerSingleton();
        }

    }

    public static void main(String[] args)
    {
        try
        {
            System.err.println("ABOUT TO GO");
            Guice.createInjector(new TestModule());
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

Original issue reported on code.google.com by irvingda...@gmail.com on 11 Apr 2014 at 8:45

GoogleCodeExporter commented 9 years ago
Same for me. It's very easy to stumble upon this problem. All you need to do is 
call one of the many new static methods for example on Comparator or Stream and 
you're dead if an exception occurs.

Original comment by Eric6i...@googlemail.com on 15 Apr 2014 at 10:01

GoogleCodeExporter commented 9 years ago

Original comment by mccu...@gmail.com on 15 Apr 2014 at 10:04

GoogleCodeExporter commented 9 years ago
I'm having this issue but I cannot figure out where it is coming from. 
Everything seems like it should work fine. I get that exact error: 
INVOKESPECIAL/STATIC on interfaces require ASM 5. Is there something I can do 
to the exact issue?

Original comment by JWelling...@gmail.com on 1 Jun 2014 at 7:15

GoogleCodeExporter commented 9 years ago
Switching to the HEAD (possibly even the beta, not sure) version should fix 
this particular issue.

Please let us know if you still see the issue after using the latest code.

Original comment by sberlin on 1 Jun 2014 at 7:55