Skip to content

Commit f2f4f86

Browse files
cpovirkGoogle Java Core Libraries
authored and
Google Java Core Libraries
committed
Suppress an unusable-by-js warning.
And enable a setting that at least _shows_ us that warning (though it doesn't fail the build). Fixes #6602 RELNOTES=Suppressed [an `unusable-by-js` warning](#6602) seen by users of `guava-gwt`. PiperOrigin-RevId: 544409394
1 parent 1dc5f8c commit f2f4f86

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

guava-gwt/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@
335335
<module>com.google.common.ForceGuavaCompilation</module>
336336
<failOnError>true</failOnError>
337337
<logLevel>${gwt.logLevel}</logLevel>
338+
<generateJsInteropExports>true</generateJsInteropExports>
338339
<validateOnly>true</validateOnly>
339340
<sourceLevel>1.8</sourceLevel>
340341
<!--

guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/Platform.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,21 @@ static <E extends Enum<E>> Class<E> getDeclaringClassOrObjectForJ2cl(E e) {
103103
return result;
104104
}
105105

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

0 commit comments

Comments
 (0)