Wednesday, February 29, 2012
Am I..??
Friday, February 17, 2012
some more things working on
- Refactoring
- Patterns of Enterprise Application Architecture
- Clean Code and other books by Robert C. Martin
- Domain Driven Design
- All McConnel Books (Rapid development, Code Complete, Software Estimation,…)
- The Pragmatic Programmer
- Implementing Lean Software Development
- The GoF book
- The Practical Guide to Defect Prevention
some more things working on
- Refactoring
- Patterns of Enterprise Application Architecture
- Clean Code and other books by Robert C. Martin
- Domain Driven Design
- All McConnel Books (Rapid development, Code Complete, Software Estimation,…)
- The Pragmatic Programmer
- Implementing Lean Software Development
- The GoF book
- The Practical Guide to Defect Prevention
Friday, February 3, 2012
Thursday, February 2, 2012
Interesting Stuff~~~!!!!
Setting "java.library.path" programmatically
When messing around with JNI, one have to set the “java.library.path” accordingly. Unfortunately the only way is to add a system property *before* the application is started:
java -Djava.library.path=/path/to/libs
Changing the system property later doesn’t have any effect, since the property is evaluated very early and cached.
But the guys over at jdic discovered a way how to work around it. It is a little bit dirty – but hey, those hacks are the reason we all love Java…
System.setProperty(
"java.library.path"
,
"/path/to/libs"
);
Field fieldSysPath = ClassLoader.
class
.getDeclaredField(
"sys_paths"
);
fieldSysPath.setAccessible(
true
);
fieldSysPath.set(
null
,
null
);
Explanation
At first the system property is updated with the new value. This might be a relative path – or maybe you want to create that path dynamically.
The Classloader has a static field (sys_paths) that contains the paths. If that field is set to null, it is initialized automatically. Therefore forcing that field to null will result into the reevaluation of the library path as soon as loadLibrary() is called…