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

Java 9 compatibility broken for QuaquaTextFieldFocusHandler #11

Open
tiberiughioca opened this issue Feb 13, 2018 · 8 comments
Open

Java 9 compatibility broken for QuaquaTextFieldFocusHandler #11

tiberiughioca opened this issue Feb 13, 2018 · 8 comments

Comments

@tiberiughioca
Copy link

Are there plans for fixing the compatibility with Java 9 for class QuaquaTextFieldFocusHandler?

@karlvr
Copy link
Owner

karlvr commented Feb 13, 2018

Not currently as I wasn’t aware of the issue! Could you please provide more details?

If you’d like to provide a fix it would be welcome.

@tiberiughioca
Copy link
Author

I am not sure how this could be solved without breaking the compatibility with earlier versions than Java 9...

Here is the actual code from master that is compatible with Java 8:

if (event instanceof CausedFocusEvent) {
 CausedFocusEvent cfEvent = (CausedFocusEvent) event;
                    if (cfEvent.getCause() == Cause.TRAVERSAL_FORWARD ||
                            cfEvent.getCause() == Cause.TRAVERSAL_BACKWARD) {
                        tc.selectAll();
                    }
                }

And here is the code that is compatible with Java 9 but breaks Java 8 compatibility:

if (event.getCause() == Cause.TRAVERSAL_FORWARD ||
                            event.getCause() == Cause.TRAVERSAL_BACKWARD) {
                        tc.selectAll();
                    }

The problem is that in Java 9 the class sun.awt.CausedFocusEvent does not exist anymore (it was removed) while in Java 8 the method java.awt.event.FocusEvent.getCause() is not available since it was added in Java 9. Any idea how we could solve this problem?

@karlvr
Copy link
Owner

karlvr commented Feb 14, 2018

We can test for the existence of sun.awt.CausedFocusEvent and set a variable to switch us between these two implementations?

@tiberiughioca
Copy link
Author

I do not think this is possible because you get an error even when you just import that class...

The right solution I think it would be to generate a multi-release jar with both implementations. But that would mean more changes regarding the structure of the project and the ant scripts. Details at http://openjdk.java.net/jeps/238

@karlvr
Copy link
Owner

karlvr commented Feb 16, 2018

Is the error that you get when you import the class about it being restricted?

@tiberiughioca
Copy link
Author

This is the error on import: "The type sun.awt.CausedFocusEvent is not visible".
And this is the error when it is used: "CausedFocusEvent cannot be resolved to a type".

And the same goes for class sun.awt.CausedFocusEvent.Cause... It is pretty easy to see these errors if you take the latest code from master and use it with Java 9.

@karlvr
Copy link
Owner

karlvr commented Feb 20, 2018

Could the code that uses CausedFocusEvent be changed to work purely with reflection? In that way it wouldn't need to import the restricted class and could avoid this error.

@brad-eric
Copy link

I was trying Quaqua 9.1 with Java 9 today & i've got the same issue!
Hope this'd be fixed some day.

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

3 participants