java - Access path variable in FileInputStream using reflection -
i came across code uses reflection "path" variable in fileinputstream!! weirder part commons.lang.reflect.fieldutils.readfield(is, "path", true) throws java.lang.illegalargumentexception. intermittently... may specific scenario leads that, not able figure out. pointers cause reflection fail "see" field?
the code buried in lot of cascading workflows related mumbo jumbo here relevant part -
//this same method invoked multiple times on same file. if matters? method(sourcecall<object, inputstream> sc) { inputstream = sc.getinput(); if (is instanceof fileinputstream) { fileinputstream fileinputstream = (fileinputstream)is; //the line below throws illegalargumentexception - string filename = (string)fieldutils.readfield(fileinputstream , "path", true); return filename; } }
you should user fieldutils.readdeclaredfield(...) access private fields.
Comments
Post a Comment