How to write an aspect or annotation for a method that cannot update any instance variables?
- 阅读更多 关于 How to write an aspect or annotation for a method that cannot update any instance variables?
问题 How to write an aspect or annotation for a method that cannot update any instance variables? Say for example I have the following java class public class Foo { String name; int id; public getName() { return name; } } Now say I want to write an aspect or in general, some annotation call it say @readOnly which can enforce getName() method to not modify either name or id so if do public class Foo { String name; int id; @readOnly public getName() { name = "hello world"; id = 7564; return name; }