I got a problem with IllegalAccessException in my program
here's my code
private static void setdata(Field field, Object dto, Object value) throws IllegalArgumentException, IllegalAccessException {
boolean accessible = field.isAccessible();
if (!accessible)
field.setAccessible(true);
if (value instanceof java.lang.String) {
if (value != null) {
value = String.valueOf(value).trim();
}
}
field.set(dto, value);
if (accessible)
field.setAccessible(false);
}
to prevent 'IllegalAccessException' I added check logic.
boolean accessible = field.isAccessible();'
if (!accessible) field.setAccessible(true);
but sometimes a IllegalAccessException is occured in my program.
the Exception raised on the line - 'field.set(dto, value);'
The Exception is as belows
java.lang.IllegalAccessException: Class com.comm.util.FileReadUtils can not access a member of class com.dto.myDto with modifiers "private"
At first, I think the 'static' is might be problem.
but as far as I know, static method do make own stack frame when it is called.
so I got nothing.
please let me know what did I do something stupid~
my program runs on Spring 3.x and java 1.6