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

[core] Use of illegal wildcard types #955

Closed
bagipro opened this issue Jun 17, 2020 · 1 comment
Closed

[core] Use of illegal wildcard types #955

bagipro opened this issue Jun 17, 2020 · 1 comment
Labels
bug Core Issues in jadx-core module

Comments

@bagipro
Copy link
Collaborator

bagipro commented Jun 17, 2020

CC from #913

Class io.reactivex.internal.operators.observable.ObservableAny

    public void subscribeActual(io.reactivex.Observer<? super java.lang.Boolean> observer) {

But java.lang.Boolean is a final class, and ? super java.lang.Boolean is illegal type

APK: https://drive.google.com/file/d/1qC3tlWs9AtPBpyS6iU9kcSphLryfJOxi/view

@bagipro bagipro added bug Core Issues in jadx-core module labels Jun 17, 2020
@skylot
Copy link
Owner

skylot commented Jul 10, 2020

@sergey-wowwow I don't see error here. Next code is correct and compiles:

    public static void test(List<? super Boolean> list) {
        list.add(Boolean.TRUE);
    }

Sure you can't insert in this list anything else instead Boolean.
Maybe you mistake ? super Boolean with ? extends Boolean ?
Anyway, these bounds include bound type, so it does not matter is class final or not, a definition will always compile. And usage in your sample is correct (check original code).

Here sample code to show differents between these bounds (JLS docs can be found here):

	class A { }
	class B extends A { }
	class C extends B { }

	public void check() {
		List<? super B> s = new ArrayList<A>(); // ok
		s.add(new A()); // error
		s.add(new B()); // ok
		s.add(new C()); // ok

		Object s0 = s.get(0); // ok
		A s1 = s.get(0); // error
		B s2 = s.get(0); // error
		C s3 = s.get(0); // error

		List<? extends B> e = new ArrayList<C>(); // ok
		e.add(new A()); // error
		e.add(new B()); // error
		e.add(new C()); // error

		Object e0 = e.get(0); // ok
		A e1 = e.get(0); // ok
		B e2 = e.get(0); // ok
		C e3 = e.get(0); // error
	}

Yeah, wildcard bounds are weird ;)

@skylot skylot closed this as completed Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

2 participants