java.lang.NullPointerException

Spring JIRA | Kazuki Shimizu | 2 years ago
  1. 0

    I used a {{@args}} as PCD(Point Cut Designator), there is case that occur a NPE at calling the unrelated method. if all of following cases are matched, NPE are occurs. * A pointcut define using a {{@args}}. * Define a both with java method that applying AOP and java method that not applying AOP. * Call a java method that not applying AOP with specifying a null parameter. {code} java.lang.NullPointerException at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.visit(ShadowMatchImpl.java:195) at org.aspectj.weaver.ast.HasAnnotation.accept(HasAnnotation.java:31) at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.matches(ShadowMatchImpl.java:132) at org.aspectj.weaver.reflect.ShadowMatchImpl.matchesJoinPoint(ShadowMatchImpl.java:87) at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:333) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:167) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) at org.springframework.issues.SampleService$$EnhancerBySpringCGLIB$$832f92bb.execute(<generated>) at org.springframework.issues.ReproTests.executeWithNull(ReproTests.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) {code} For example: *Target Class* {code:java} public class SampleService { /** * Not matched method on {@link LoggingAspect}. */ public void execute(SampleInputBean inputBean) { System.out.println(getClass().getName() + "#execute(SampleInputBean) called."); } /** * Matched method on {@link LoggingAspect} * <p> * The SampleDto class have a {@link Loggable} annotation. */ public void execute(SampleDto dto) { System.out.println(getClass().getName() + "#execute(SampleDto) called."); } } {code} *Aspect* {code:java} @Aspect public class LoggingAspect { @Before("@args(org.springframework.issues.Loggable))") public void loggingBeginByAtArgs() { System.out.println("★★★start by @args★★★★"); } } {code} *JavaBean(TDO)* {code:java} @Loggable public class SampleDto { } {code} {code:java} public class SampleInputBean { } {code} *Test Case* {code:java} @Test public void test() { ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("org/springframework/issues/ReproTests-context.xml"); ctx.registerShutdownHook(); SampleService sampleService = ctx.getBean("sampleService", SampleService.class); sampleService.execute(new SampleDto()); // -> OK sampleService.execute(new SampleInputBean()); // -> OK sampleService.execute((SampleDto)null); // -> OK sampleService.execute((SampleInputBean)null); // -> NPE } {code}

    Spring JIRA | 2 years ago | Kazuki Shimizu
    java.lang.NullPointerException
  2. 0

    I used a {{@args}} as PCD(Point Cut Designator), there is case that occur a NPE at calling the unrelated method. if all of following cases are matched, NPE are occurs. * A pointcut define using a {{@args}}. * Define a both with java method that applying AOP and java method that not applying AOP. * Call a java method that not applying AOP with specifying a null parameter. {code} java.lang.NullPointerException at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.visit(ShadowMatchImpl.java:195) at org.aspectj.weaver.ast.HasAnnotation.accept(HasAnnotation.java:31) at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.matches(ShadowMatchImpl.java:132) at org.aspectj.weaver.reflect.ShadowMatchImpl.matchesJoinPoint(ShadowMatchImpl.java:87) at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:333) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:167) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) at org.springframework.issues.SampleService$$EnhancerBySpringCGLIB$$832f92bb.execute(<generated>) at org.springframework.issues.ReproTests.executeWithNull(ReproTests.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) {code} For example: *Target Class* {code:java} public class SampleService { /** * Not matched method on {@link LoggingAspect}. */ public void execute(SampleInputBean inputBean) { System.out.println(getClass().getName() + "#execute(SampleInputBean) called."); } /** * Matched method on {@link LoggingAspect} * <p> * The SampleDto class have a {@link Loggable} annotation. */ public void execute(SampleDto dto) { System.out.println(getClass().getName() + "#execute(SampleDto) called."); } } {code} *Aspect* {code:java} @Aspect public class LoggingAspect { @Before("@args(org.springframework.issues.Loggable))") public void loggingBeginByAtArgs() { System.out.println("★★★start by @args★★★★"); } } {code} *JavaBean(TDO)* {code:java} @Loggable public class SampleDto { } {code} {code:java} public class SampleInputBean { } {code} *Test Case* {code:java} @Test public void test() { ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("org/springframework/issues/ReproTests-context.xml"); ctx.registerShutdownHook(); SampleService sampleService = ctx.getBean("sampleService", SampleService.class); sampleService.execute(new SampleDto()); // -> OK sampleService.execute(new SampleInputBean()); // -> OK sampleService.execute((SampleDto)null); // -> OK sampleService.execute((SampleInputBean)null); // -> NPE } {code}

    Spring JIRA | 2 years ago | Kazuki Shimizu
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.visit()
    2. AspectJ weaver
      ShadowMatchImpl.matchesJoinPoint
      1. org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.visit(ShadowMatchImpl.java:195)
      2. org.aspectj.weaver.ast.HasAnnotation.accept(HasAnnotation.java:31)
      3. org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.matches(ShadowMatchImpl.java:132)
      4. org.aspectj.weaver.reflect.ShadowMatchImpl.matchesJoinPoint(ShadowMatchImpl.java:87)
      4 frames
    3. Spring AOP
      CglibAopProxy$DynamicAdvisedInterceptor.intercept
      1. org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:333)
      2. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:167)
      3. org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
      4. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      5. org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
      5 frames
    4. org.springframework.issues
      ReproTests.executeWithNull
      1. org.springframework.issues.SampleService$$EnhancerBySpringCGLIB$$832f92bb.execute(<generated>)
      2. org.springframework.issues.ReproTests.executeWithNull(ReproTests.java:32)
      2 frames
    5. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      3 frames
    6. JUnit
      JUnitCore.run
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      5. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      8. org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      9. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      10. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      11. org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      12. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      13. org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      14. org.junit.runner.JUnitCore.run(JUnitCore.java:160)
      14 frames
    7. IntelliJ junit4 module
      JUnit4IdeaTestRunner.startRunnerWithArgs
      1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
      1 frame
    8. IDEA
      JUnitStarter.main
      1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
      2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
      2 frames
    9. Java RT
      NativeMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      2 frames
    10. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
      1 frame