Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 148799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:01:22+00:00 2026-05-11T09:01:22+00:00

While setting up Hudson for continous integration testing (on a JeOS server), I’ve come

  • 0

While setting up Hudson for continous integration testing (on a JeOS server), I’ve come across some strange behaviour I’m hoping the fine people at SO can explain to me.

Our unit tests depend heavily on the use of domain objects, with lots of properties that must be set (due to null constraints in the database). In order to keep our tests readable, we have created a class InstantiationUtils that can instantiate an object and set a series of properties through reflection:

public static <T> T newInstance(final Class<T> type, final KeyValuePair<?>... propertyValues) {      return ReflectionUtils.reflectionOperation(new ReflectionOperation<T>() {          @Override         public T perform() throws Exception {              T object = type.newInstance();             for (KeyValuePair<?> propertyValue : propertyValues) {                  String propertyName = propertyValue.getKey();                 Object value = propertyValue.getValue();                 String setterName = 'set' + StringUtils.capitalize(propertyName);                 ReflectionUtils.invoke(object, setterName, value);             }             return object;         }     }); }  public static void invoke(final Object target, final String methodName, final Object... params) {      List<Class<?>> parameterTypes = ListUtils.map(asList(params), 'class');     Class<?> targetClass = target.getClass();     Method method = MethodUtils.getMatchingAccessibleMethod(targetClass, methodName,         parameterTypes.toArray(new Class<?>[] {}));     invoke(target, method, params); }  public class Foo {     private String foo;      public void setFoo(final String foo) {         this.foo = foo;     } }  public class Bar extends Foo {     private String bar;      public void setBar(final String bar) {        this.bar = bar;     } } 

The person who wrote this code unfortunately no longer works for us, but as far as I can see, there is nothing wrong with it. Which is also true for Windows – we use InstantiationUtils throughout our unit tests without any problems.

Linux, however, is different. It turns out that in Linux, the newInstance() method only works for direct (i.e. not inherited) members of the class we want to instantiate.

InstantiationUtils.newInstance(Bar.class, ‘bar’, ‘12345’); will work, while InstantiationUtils.newInstance(Bar.class, ‘foo’, ‘98765’); will fail on Linux, with the following exception:

xxx.xxx.xxx.ReflectionUtils$ReflectionException: java.lang.NoSuchMethodException: Property ‘foo’ has no setter method

On Windows, both calls will work (I know the newInstance signature doesn’t match; we have several overloaded newInstance() methods that convert the parameters to KeyValuePairs).

I had a hard time accepting that inherited public methods are treated differently, so I have tested this in all ways I can think of. And it always ends up with the conclusion that under Linux, at least with the above usage of Reflection, we can’t access public inherited methods.

On Windows, I use Sun’s JRE 1.6.0.11, in Linux it’s also Sun, but version 1.6.0.7.

Can anyone confirm if this is correct? Or is the Reflection usage somehow flawed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:01:23+00:00Added an answer on May 11, 2026 at 9:01 am

    Mystery partially solved:

    MethodUtils.getMatchingAccessibleMethod() apparently works differently on Linux and Windows.

    By using MethodUtils.getAccessibleMethod() instead, it works. Why, I don’t know, but I’m guessing that MethodUtils somehow misinterprets the parameter list when figuring out what signature the Method should have.

    I’d like to spend more time investigating this, but as always there are things to do and projects to deliver, so I just have to accept that getAccessibleMethod works, and move on 🙂

    Thanks to everyone for their input!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 133k
  • Answers 133k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The simple way is to create a special header that… May 12, 2026 at 6:39 am
  • Editorial Team
    Editorial Team added an answer If I remember correctly, you can't. The currently selected configuration… May 12, 2026 at 6:39 am
  • Editorial Team
    Editorial Team added an answer Well you would have to define a format to play… May 12, 2026 at 6:39 am

Related Questions

While setting up Hudson for continous integration testing (on a JeOS server), I've come
I am in the process of researching/setting up a Continuous Integration Server for a
I'm looking into setting up a CI environment for our flex projects. I have
I'm working with a small (4 person) development team on a C# project. I've
While setting up CruiseControl, I added a buildpublisher block to the publisher tasks: <buildpublisher>

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.