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

IllegalArgumentException on UIKey.getKeyCode() #548

Closed
MrStahlfelge opened this issue Dec 30, 2020 · 2 comments
Closed

IllegalArgumentException on UIKey.getKeyCode() #548

MrStahlfelge opened this issue Dec 30, 2020 · 2 comments

Comments

@MrStahlfelge
Copy link

Please ensure you have given all the following requested information in your report.

Issue details

Calling 'UIKey.getKeyCode()` can throw an IllegalArgumentException (see below).

The enum is not complete, 669 seems to be the "Globe key" on some magic keyboards.

Versions:

Please provide the version of RoboVM, XCode and JDK used

  • Robovm: 2.3.12
  • XCode:
  • JDK: OpenJDK 8

Build Targets:
arm64


Stacktrace

java.lang.IllegalArgumentException: No constant with value 669 (0x29d) found in org.robovm.apple.uikit.UIKeyboardHIDUsage
	at org.robovm.rt.bro.ValuedEnum$AsLongMarshaler.toObject(ValuedEnum.java:142)
	at org.robovm.rt.bro.ValuedEnum$AsMachineSizedSIntMarshaler.toObject(ValuedEnum.java:158)
	at org.robovm.apple.uikit.UIKey.$m$keyCode(Native Method)
	at org.robovm.apple.uikit.UIKey.getKeyCode(UIKey.java)
	at com.badlogic.gdx.backends.iosrobovm.DefaultIOSInput.onKey(DefaultIOSInput.java:660)
dkimitsa added a commit to dkimitsa/robovm that referenced this issue Jan 12, 2021
… introduces EnumConstantMissingException to be used when constant is can't be marshaled into Enum value

- `UIKey.getKeyCodeRaw()` is a workaround for MobiVM#548 to allow retrieve codes that are not present in `UIKeyboardHIDUsage`
- `EnumConstantMissingException` extends `IllegalArgumentException` and will be thrown instead of last by `ValuedEnum` in case constant is can't be marshaled. It also contains constant value. Existing code that catches `IllegalArgumentException` will not be affected
@dkimitsa
Copy link
Contributor

it is not possible to fix missing valued in enum without switching from enum to raw int.
an workaround -- method to return RAW integer added as part of #551

@MrStahlfelge
Copy link
Author

The added method and new exception looks good to me, keeps backwards compatiblity and is a good addition. Thanks in advance!

dkimitsa added a commit to dkimitsa/robovm that referenced this issue Jan 20, 2021
fix for MobiVM#548 is not working as expected as produce:
```
org.robovm.compiler.CompilerException: Found multiple overridable @method or @Property methods in org.robovm.apple.uikit.UIKey with the selector 'keyCode'.
```

the fix is not to use same @Property annotation but implement getKeyCode with separate implementation that calls getKeyCodeRaw
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

No branches or pull requests

2 participants