Last active
November 14, 2017 08:03
-
-
Save mike-neck/8556b12f99f23dccd7825b6d92c2a1c6 to your computer and use it in GitHub Desktop.
古いASMでコケるやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
com.google.inject.internal.util.$ComputationException: java.lang.ArrayIndexOutOfBoundsException: 871 | |
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553) | |
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419) | |
at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041) | |
at com.google.inject.internal.util.$StackTraceElements.forMember(StackTraceElements.java:53) | |
at com.google.inject.internal.Errors.formatSource(Errors.java:690) | |
at com.google.inject.internal.Errors.format(Errors.java:555) | |
at com.google.inject.ProvisionException.getMessage(ProvisionException.java:59) | |
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391) | |
at java.lang.Throwable.toString(Throwable.java:480) | |
at java.lang.String.valueOf(String.java:2994) | |
at java.io.PrintWriter.println(PrintWriter.java:754) | |
at java.lang.Throwable$WrappedPrintWriter.println(Throwable.java:764) | |
at java.lang.Throwable.printStackTrace(Throwable.java:655) | |
at java.lang.Throwable.printStackTrace(Throwable.java:721) | |
at org.junit.runner.notification.Failure.getTrace(Failure.java:75) | |
at com.intellij.junit4.JUnit4TestListener.getTrace(JUnit4TestListener.java:288) | |
at com.intellij.junit4.JUnit4TestListener.testFailure(JUnit4TestListener.java:270) | |
at com.intellij.junit4.JUnit4TestListener.testFailure(JUnit4TestListener.java:222) | |
at com.intellij.junit4.JUnit4TestListener.testFailure(JUnit4TestListener.java:200) | |
at org.junit.runner.notification.SynchronizedRunListener.testFailure(SynchronizedRunListener.java:63) | |
at org.junit.runner.notification.RunNotifier$4.notifyListener(RunNotifier.java:142) | |
at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72) | |
at org.junit.runner.notification.RunNotifier.fireTestFailures(RunNotifier.java:138) | |
at org.junit.runner.notification.RunNotifier.fireTestFailure(RunNotifier.java:132) | |
at org.junit.internal.runners.model.EachTestNotifier.addFailure(EachTestNotifier.java:23) | |
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:329) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) | |
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) | |
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) | |
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) | |
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) | |
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) | |
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) | |
at org.junit.runner.JUnitCore.run(JUnitCore.java:137) | |
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) | |
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) | |
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) | |
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) | |
Caused by: java.lang.ArrayIndexOutOfBoundsException: 871 | |
at com.google.inject.internal.asm.$ClassReader.readClass(Unknown Source) | |
at com.google.inject.internal.asm.$ClassReader.accept(Unknown Source) | |
at com.google.inject.internal.asm.$ClassReader.accept(Unknown Source) | |
at com.google.inject.internal.util.$LineNumbers.<init>(LineNumbers.java:62) | |
at com.google.inject.internal.util.$StackTraceElements$1.apply(StackTraceElements.java:36) | |
at com.google.inject.internal.util.$StackTraceElements$1.apply(StackTraceElements.java:33) | |
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549) | |
... 38 more |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.hamcrest.CoreMatchers.is; | |
import static org.hamcrest.MatcherAssert.assertThat; | |
import java.util.Optional; | |
import javax.inject.Provider; | |
import org.junit.Test; | |
import com.google.inject.AbstractModule; | |
import com.google.inject.Guice; | |
import com.google.inject.Injector; | |
import com.google.inject.Key; | |
import com.google.inject.Provides; | |
import com.google.inject.TypeLiteral; | |
public class Java8Compatibility { | |
@FunctionalInterface | |
public interface Fun<A, B> { | |
B apply(A a); | |
default Optional<B> applyOptional(final A a) { | |
return Optional.ofNullable(this.apply(a)); | |
} | |
} | |
@Test | |
public void lambdaInModule() { | |
final Injector injector = Guice.createInjector(new FunMod()); | |
final Fun<String, Integer> fun = | |
injector.getInstance(Key.get(new TypeLiteral<Fun<String, Integer>>() {})); | |
assertThat(fun.applyOptional("foo"), is(Optional.of(3))); | |
} | |
public static class FunMod extends AbstractModule { | |
@Override | |
protected void configure() { | |
} | |
@Provides | |
public Fun<String, Integer> function() { | |
if ("foo".length() == 3) { | |
throw new IllegalStateException("something wrong."); | |
} | |
final Provider<Fun<String, Integer>> provider = () -> String::length; | |
return provider.get(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment