Если эта константа является метаданными о классе, я бы сделал это с аннотациями :
Первый шаг, объявить аннотацию:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface Abc {
String value();
}
Шаг второй, комментируйте свой класс:
@Abc("Hello, annotations!")
class Zomg {
}
Шаг третий, получить значение:
String className = "com.example.Zomg";
Class<?> klass = Class.forName(className);
Abc annotation = klass.getAnnotation(Abc.class);
String abcValue = annotation.value();
System.out.printf("Abc annotation value for class %s: %s%n", className, abcValue);
Вывод:
Abc annotation value: Hello, annotations!