When I use setModifiers(Constants.ACC_PUBLIC) the other attributes such as
static, final etc are not retained. The field modifier is then set to just
public. I tried using bitwise OR of Constants.ACC_PUBLIC with existing
modifiers and noticed that it retains the other access attributes and also
changes the field modifier to public. But doesnt works for protected
fields as bitwise OR results in 0x5 value which is not valid value.

You need to clear out the other access bits first. E.g.

 int modifiers = member.getModifiers();
 modifiers &= ~(Constants.ACC_PRIVATE|Constants.ACC_PROTECTED);
 modifiers |= Constants.ACC_PUBLIC;
 member.setModifiers(modifiers);

But really is much much simpler to just do:

 member.isPrivate(false);
 member.isProtected(false);
 member.isPublic(true);

Cheers,
Ray Blaak


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to