Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct Enum field with unsigned values #126

Closed
goto1134 opened this issue Jun 29, 2017 · 1 comment · May be fixed by #127
Closed

Struct Enum field with unsigned values #126

goto1134 opened this issue Jun 29, 2017 · 1 comment · May be fixed by #127

Comments

@goto1134
Copy link
Contributor

There is a enum

public enum LockMode
        implements IntegerEnum
{
  Locked(0x00),
  Unlocked(0x04),
  Unknown(0xFF);

  ReaderMode(int aValue)
  {
    value = aValue;
  }

  @Override
  public int intValue()
  {
    return value;
  }

  private final int value;
}

But when it is used as value for Enum8 field of Struct there is an exception when the value is Unknown that says:

java.lang.IllegalArgumentException: No known Enum mapping for value -1 of type lock.LockMode

The problem is that Unknown field has value of 0xFF, which is -1 in byte equivalent.

I think, it would be better if jnr.ffi.util.EnumMapper will compare unsigned values.

@goto1134
Copy link
Contributor Author

Fixed with #127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant