Skip to content

Suppress an unusable-by-js warning. #6608

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions guava-gwt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
<module>com.google.common.ForceGuavaCompilation</module>
<failOnError>true</failOnError>
<logLevel>${gwt.logLevel}</logLevel>
<generateJsInteropExports>true</generateJsInteropExports>
<validateOnly>true</validateOnly>
<sourceLevel>1.8</sourceLevel>
<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,21 @@ static <E extends Enum<E>> Class<E> getDeclaringClassOrObjectForJ2cl(E e) {
return result;
}

/*
* If I understand correctly:
*
* This needs to be a @JsMethod so that J2CL knows to look for a JavaScript implemention of
* it in Platform.native.js. (The JavaScript implementation inline below is visible to *GWT*, but
* *J2CL* doesn't look at it.)
*
* However, once it's a @JsMethod, GWT produces a warning. That's because (a) the *other* purpose
* of @JsMethod is to make a method *callable* from JavaScript and (b) this method would not be
* useful to call from vanilla JavaScript because it returns an instance of Class, which can't be
* converted to a standard JavaScript type. (Contrast to something like String or boolean.) Since
* we're not calling it from JavaScript, we suppress the warning.
*/
@JsMethod
@SuppressWarnings("unusable-by-js")
private static native <E extends Enum<E>> @Nullable Class<E> getDeclaringClassOrNullForJ2cl(
E e) /*-{
return [email protected]::getDeclaringClass()();
Expand Down