Skip to content

Add a compile-time switch for RPC enhanced classes - #10386

Open
kamexETH wants to merge 2 commits into
gwtproject:mainfrom
kamexETH:fix-9881-disable-enhanced-classes
Open

Add a compile-time switch for RPC enhanced classes#10386
kamexETH wants to merge 2 commits into
gwtproject:mainfrom
kamexETH:fix-9881-disable-enhanced-classes

Conversation

@kamexETH

@kamexETH kamexETH commented Aug 1, 2026

Copy link
Copy Markdown

Add the single-valued rpc.enhancedClasses.enabled configuration
property, defaulting to true for compatibility.

When set to false, RPC ignores both JPA/JDO enhancement annotations and
the rpc.enhancedClasses list. Generated field serializers omit the opaque
server-enhanced payload, serialization policies omit @ClientFields, and the
server no longer sees those JPA/JDO fields when clients return them.

Missing, malformed, or multi-valued settings log a warning and retain the
backwards-compatible enabled behavior. The enhanced-class settings are also
included in RPC generator cache validation, preventing field serializers
generated under different settings from being reused.

Tests:

  • ant -f user/build.xml -Dgwt.nongwt.testcase.includes="**/RpcJreSuite.class" test.nongwt
  • ant -f user/build.xml checkstyle

Fixes #9881

@niloc132 niloc132 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! A few comments:

return Boolean.parseBoolean(prop.getValues().get(0));
}
} catch (BadPropertyValueException e) {
// Preserve the historical behavior when compiling without the new property.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this, given that you also changed RemoteService.gwt.xml?

@kamexETH kamexETH Aug 5, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed—the inherited module normally guarantees the property. I kept only a warned, backwards-compatible fallback for custom modules that replace or do not inherit RemoteService.gwt.xml: a missing or malformed value now logs a warning and returns true.

Comment thread user/src/com/google/gwt/user/rebind/rpc/Shared.java
Controls whether RPC generates support for server-enhanced classes. Set
this to false to ignore both JPA/JDO annotations and the
rpc.enhancedClasses list, preventing @ClientFields entries and the
corresponding client-side payload handling from being generated.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe tie this back to the actual server behavior being lost through this?

Something like

Suggested change
corresponding client-side payload handling from being generated.
corresponding client-side payload handling from being generated
and so the server from seeing JPA/JDO fields returned to it from
client calls

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the module documentation to make the server-side consequence explicit: when disabled, the server cannot see the JPA/JDO fields returned to it from client calls.

*/

if (serializableClass.isEnhanced()) {
if (Shared.isEnhancedClass(context.getPropertyOracle(), serializableClass)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very late to check this - could we instead just not set isEnhanced as you've already done so that this check fails?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I removed the late property checks and restored the direct serializableClass.isEnhanced() checks. The builder now remains the single place that decides whether to mark a type as enhanced.

* Returns whether the type should be treated as enhanced for the current compilation.
*/
static boolean isEnhancedClass(PropertyOracle propertyOracle, JClassType type) {
return shouldEnableEnhancedClasses(propertyOracle) && type.isEnhanced();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do need this, contrary to my comment in FieldSerializerCreator, let's swap the && and do the cheap field check before the map lookups

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed Shared.isEnhancedClass entirely, so there is no property lookup at this late stage. FieldSerializerCreator and ProxyCreator now use the direct isEnhanced() checks again.

Signed-off-by: kamex <kamexETH@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Compile-time configuration to disable rpc.enhancedClasses feature

2 participants