Getting the name of a method parameter

Parameter names are available if you have told the compiler to include them (compile with debug information). Spring has ParameterNameDiscoverer which can help you obtain the names. The default implementation uses asm ClassReader to do so. With javac you should include the -g argument to include debug information. With Eclipse I think it is there … Read more

How to use TLS 1.2 in Java 6

After a few hours of playing with the Oracle JDK 1.6, I was able to make it work without any code change. The magic is done by Bouncy Castle to handle SSL and allow JDK 1.6 to run with TLSv1.2 by default. In theory, it could also be applied to older Java versions with eventual … Read more

Using File.listFiles with FileNameExtensionFilter

The FileNameExtensionFilter class is intended for Swing to be used in a JFileChooser. Try using a FilenameFilter instead. For example: File dir = new File(“/users/blah/dirname”); File[] files = dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(“.txt”); } });

Is it possible to read the value of a annotation in java?

Yes, if your Column annotation has the runtime retention @Retention(RetentionPolicy.RUNTIME) @interface Column { …. } you can do something like this for (Field f: MyClass.class.getFields()) { Column column = f.getAnnotation(Column.class); if (column != null) System.out.println(column.columnName()); } UPDATE : To get private fields use Myclass.class.getDeclaredFields()

Java 1.6 – determine symbolic links

The technique used in Apache Commons uses the canonical path to the parent directory, not the file itself. I don’t think that you can guarantee that a mismatch is due to a symbolic link, but it’s a good indication that the file needs special treatment. This is Apache code (subject to their license), modified for … Read more