Luke - 2019-01-24

Is possible to implement a custom rule to identify if any caller is caching an annotated method data?
For example

    public class MyCache {
        private static MyCache i = new MyCache();
        private Map<String> data;
        private MyCache() { /* init data */ }
        public static MyCache getInstance() { return i; }
        @NotCachable
        public Map<String> getData() { return data; }
    }

    public class Caller1() {
        private Map<String> data;

        public void foo() { //ERROR!
            this.data = MyCache.getInstance().getData();
        }
    }

    public class Caller2() {
        private Map<String> updated;

        public void foo1() { //ERROR!
            Map<String> a = MyCache.getInstance().getData();
            this.updated = doSomething(a); //do something on data and cache a derived value
        }

        public void foo2() { //OK
            Map<String> a = MyCache.getInstance().getData();
            System.out.println(a.get("a"));         
        }
    }

My request is to search in all classpath if any caller of a method annotated with custom annotation (for example @NotCachable) is just using the data or recaching it in some way.

Thank you.