Announcement Announcement Module

JavaConfig forum decommissioned in favor of Core Container

As described at

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at
See more
See less
Code Obfuscation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Code Obfuscation

    My PM is asking for Code Obfuscation to stop reverse engineering.

    If I obfuscate my code then class names would be changed and I would have to re write my spring applicationcontext file. Is there any support or easy ideas to achieve that ?


  • #2
    It sounds like you're currently using XML to configure your application, but you've posted in the right place - the Spring JavaConfig project is a perfect solution for those that need obfuscation. Essentially, you'll drop using XML and start writing your configurations in pure java.

        <bean id="foo" class="com.myco.Foo"/>
    and you would access that bean as follows:
    ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
    Foo foo = (Foo) ctx.getBean("foo");
    In this situation, you're quite right - obfuscation would render the beans.xml file inaccurate and the configuration would not work.

    Here's the same configuration using JavaConfig:
    public class AppConfig {
        public @Bean Foo foo() {
            return new Foo();
    And bootstrapping goes as follows:
    JavaConfigApplicationContext ctx = new JavaConfigApplicationContext(Foo.class);
    Foo foo = ctx.getBean(Foo.class);
    As you can see, with JavaConfig it's 100% Java - no XML, no string identifiers, so everything will obfuscate together and work perfectly.

    Hope this gives you what you're looking for!