private String getLocalizedString(String key, Object... args) {
        String[] strings = new String[args.length];
        for (int i = 0; i < strings.length; i++) {
            Object arg = args[i];
            if (arg == null)
                strings[i] = null;
            else if (arg instanceof FileObject)
                strings[i] = ((FileObject) arg).getName();
            else if (arg instanceof JCDiagnostic)
                strings[i] = ((JCDiagnostic) arg).getMessage(null);
            else
                strings[i] = arg.toString();
        }

        return messages.getLocalizedString(key, (Object[]) strings);
    }