Why the continue () function gives an error

I have the following aspect:

aspect NullifyNoResultException { Object around(..) : execution(public Object com.example.*.*(..) { try { return proceed(); } catch (NoResultException e) { return null; } } } } 

For some reason, a call to continue gives an error in Eclipse:

The continue () method is undefined for type NullifyNoResultException

When I build in maven -> mvn install , I get no errors. But this does not make sense, because I still do not have enough import for NoResultException , so maven should complain about it.
Instead, he simply builds and does not complain.

How to make Eclipse stop complaining about proceed() ?
and how do I get this aspect to build?

+4
source share
1 answer

I found some syntax errors in your sample code. When I fix them, the following example works fine. BTW, I defined my own NoResultException because I don't have Java EE.

 package javax.persistence; public class NoResultException extends RuntimeException { private static final long serialVersionUID = 1L; } 
 package com.example.stackoverflow; import javax.persistence.NoResultException; public class Application { public static void main(String[] args) { Application app = new Application(); System.out.println(app.valueReturningMethod(1, "two")); System.out.println(app.exceptionThrowingMethod(1, "two")); } public Object valueReturningMethod(int i, String string) { return "normal result"; } public Object exceptionThrowingMethod(int i, String string) { throw new NoResultException(); } } 
 package com.example.stackoverflow; import javax.persistence.NoResultException; aspect NullifyNoResultException { Object around() : execution(public Object com.example..*(..)) { try { return proceed(); } catch (NoResultException e) { return null; } } } 

The output will be as expected:

 normal result null 
+2
source

All Articles