java - How to extract annotation arguments into external file? -
i have following class.
public class multipartfilewrapper { @extensions({".jpg",".png",".gif",".bmp",".mp4"}) multipartfile multipartfile; ... }
now want extract formats configuration file. don't understand how replace
@extensions({".jpg",".png",".gif",".bmp",".mp4"})
i want rewrite this:
public class multipartfilewrapper { @extensions(readformatsfromfile()) multipartfile multipartfile; ... }
formats should takes external file following content:
.jpg,.png,.gif,.bmp,.mp4
does java allow this?
attribute values must constant.
from java language specification, section 9.7.1, emphasis mine:
java not allow runtime annotation arguments: annotation parameters stored @ compile-time, , hence cannot dynamic.
if t primitive type or string, , v constant expression (§15.28).
v not null.
if t class, or invocation of class, , v class literal (§15.8.2).
if t enum type, , v enum constant.
in case, v
not constant expression.
aside this, many annotations may not preserved in compiled code unless explicitly specified via @retention(retentionpolicy.runtime)
.
Comments
Post a Comment