Monday, September 17, 2012
Tuesday, September 4, 2012
Invoking parent private method by reflection
boolean superField = true;
private void superMethod(boolean superField) {System.out.println("superMethod() called - param:" + superField);
}
}
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public static void main(String args[]) {
SubClass subClassInstance = new SubClass();
try {
Method declaredMethod = SuperClass.class.getDeclaredMethod("superMethod", boolean.class);
declaredMethod.setAccessible(true);
declaredMethod.invoke((SuperClass)subClassInstance, new Object[] {false}); //I remember that there was a situation this explicit cast is required
} catch (NoSuchMethodException e) {} catch (SecurityException e) {
} catch (IllegalAccessException e) {
} catch (IllegalArgumentException e) {
} catch (InvocationTargetException e) {
}
}
}
Sunday, July 1, 2012
JVM HIGH LOAD WITHOUT ANY REASON (JAVA LEAP YEAR BUG)
Yes, I spent the whole day on this, someone saved my life:
http://blog.wpkg.org/2012/07/01/java-leap-second-bug-30-june-1-july-2012-fix/
http://blog.wpkg.org/2012/07/01/java-leap-second-bug-30-june-1-july-2012-fix/
Friday, March 30, 2012
MapQuest Android MapView vs Google Android MapView
Problem: Cannot align the MapView properly in MapQuest.
Solution: Do your own bit-wise OR!!!
Google Android MapView LayoutParams:
int a = MapView.LayoutParams.BOTTOM_CENTER; //81
int b = MapView.LayoutParams.BOTTOM; //80
int c = MapView.LayoutParams.CENTER_HORIZONTAL; //1
int d = MapView.LayoutParams.BOTTOM | MapView.LayoutParams.CENTER_HORIZONTAL; // 81
it makes sense, doesn't it?
How about MapQuest Android MapView LayoutParams?
int a = MapView.LayoutParams.BOTTOM_CENTER; //35
int b = MapView.LayoutParams.BOTTOM; //32
int c = MapView.LayoutParams.CENTER_HORIZONTAL; //1
int d = MapView.LayoutParams.BOTTOM | MapView.LayoutParams.CENTER_HORIZONTAL; // 33
hmmm...something doesn't seem right here...
Subscribe to:
Posts (Atom)