forked from google/guava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cases where GWT sometimes couldn't infer which types are serialized.
And finally revise our (internal-only) tests to catch these problems and the problem fixed by CL 147488537. As far as I can tell, our old tests passed only because of a GWT bug. The fixes are mostly to create dummy superclasses with dummy fields, as usual. The exception is ImmutableSortedSet. For some reason, the fix there is to move the existing dummy fields to RegularImmutableSortedSet. My completely wild guess (without investigating at all) is that GWT ignores the ImmutableSortedSet fields because ImmutableSortedSet_CustomFieldSerializer doesn't have the expected methods. This guess makes no sense, especially because GWT appears to be fine with the *Comparator<E>* field on ImmutableSortedSet, just not the E field. Basically nothing makes any sense, but I'm just happy it works now. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=147607863
- Loading branch information
Showing
14 changed files
with
286 additions
and
11 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ollect/super/com/google/common/collect/ArrayListMultimapGwtSerializationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2016 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.common.collect; | ||
|
||
import com.google.common.annotations.GwtCompatible; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
@GwtCompatible(emulated = true) | ||
abstract class ArrayListMultimapGwtSerializationDependencies<K, V> | ||
extends AbstractListMultimap<K, V> { | ||
ArrayListMultimapGwtSerializationDependencies(Map<K, Collection<V>> map) { | ||
super(map); | ||
} | ||
|
||
K dummyKey; | ||
V dummyValue; | ||
} |
31 changes: 31 additions & 0 deletions
31
...mon/collect/super/com/google/common/collect/HashMultimapGwtSerializationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2016 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.common.collect; | ||
|
||
import com.google.common.annotations.GwtCompatible; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
@GwtCompatible(emulated = true) | ||
abstract class HashMultimapGwtSerializationDependencies<K, V> extends AbstractSetMultimap<K, V> { | ||
HashMultimapGwtSerializationDependencies(Map<K, Collection<V>> map) { | ||
super(map); | ||
} | ||
|
||
K dummyKey; | ||
V dummyValue; | ||
} |
24 changes: 24 additions & 0 deletions
24
...ollect/super/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2016 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.common.collect; | ||
|
||
import com.google.common.annotations.GwtCompatible; | ||
|
||
@GwtCompatible(emulated = true) | ||
abstract class ImmutableMultisetGwtSerializationDependencies<E> extends ImmutableCollection<E> { | ||
E dummy; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...llect/super/com/google/common/collect/LinkedHashMultimapGwtSerializationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2016 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.common.collect; | ||
|
||
import com.google.common.annotations.GwtCompatible; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
@GwtCompatible(emulated = true) | ||
abstract class LinkedHashMultimapGwtSerializationDependencies<K, V> | ||
extends AbstractSetMultimap<K, V> { | ||
LinkedHashMultimapGwtSerializationDependencies(Map<K, Collection<V>> map) { | ||
super(map); | ||
} | ||
|
||
K dummyKey; | ||
V dummyValue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
guava/src/com/google/common/collect/ArrayListMultimapGwtSerializationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2016 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.common.collect; | ||
|
||
import com.google.common.annotations.GwtCompatible; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
/** | ||
* A dummy superclass to support GWT serialization of the element types of an {@link | ||
* ArrayListMultimap}. The GWT supersource for this class contains a field for each type. | ||
* | ||
* <p>For details about this hack, see {@link GwtSerializationDependencies}, which takes the same | ||
* approach but with a subclass rather than a superclass. | ||
* | ||
* <p>TODO(cpovirk): Consider applying this subclass approach to our other types. | ||
*/ | ||
@GwtCompatible(emulated = true) | ||
abstract class ArrayListMultimapGwtSerializationDependencies<K, V> | ||
extends AbstractListMultimap<K, V> { | ||
ArrayListMultimapGwtSerializationDependencies(Map<K, Collection<V>> map) { | ||
super(map); | ||
} | ||
// TODO(cpovirk): Maybe I should have just one shared superclass for AbstractMultimap itself? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
guava/src/com/google/common/collect/HashMultimapGwtSerializationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2016 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.common.collect; | ||
|
||
import com.google.common.annotations.GwtCompatible; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
/** | ||
* A dummy superclass to support GWT serialization of the element types of a {@link HashMultimap}. | ||
* The GWT supersource for this class contains a field for each type. | ||
* | ||
* <p>For details about this hack, see {@link GwtSerializationDependencies}, which takes the same | ||
* approach but with a subclass rather than a superclass. | ||
* | ||
* <p>TODO(cpovirk): Consider applying this subclass approach to our other types. | ||
*/ | ||
@GwtCompatible(emulated = true) | ||
abstract class HashMultimapGwtSerializationDependencies<K, V> extends AbstractSetMultimap<K, V> { | ||
HashMultimapGwtSerializationDependencies(Map<K, Collection<V>> map) { | ||
super(map); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
guava/src/com/google/common/collect/ImmutableMultisetGwtSerializationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2016 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.common.collect; | ||
|
||
import com.google.common.annotations.GwtCompatible; | ||
|
||
/** | ||
* A dummy superclass to support GWT serialization of the element type of an {@link | ||
* ImmutableMultiset}. The GWT supersource for this class contains a field of type {@code E}. | ||
* | ||
* <p>For details about this hack, see {@link GwtSerializationDependencies}, which takes the same | ||
* approach but with a subclass rather than a superclass. | ||
* | ||
* <p>TODO(cpovirk): Consider applying this subclass approach to our other types. | ||
* | ||
* <p>For {@code ImmutableMultiset} in particular, I ran into a problem with the {@code | ||
* GwtSerializationDependencies} approach: When autogenerating a serializer for the new class, GWT | ||
* tries to refer to our dummy serializer for the superclass, | ||
* ImmutableMultiset_CustomFieldSerializer. But that type has no methods (since it's never actually | ||
* used). We could probably fix the problem by adding dummy methods to that class, but that is | ||
* starting to sound harder than taking the superclass approach, which I've been coming to like, | ||
* anyway, since it doesn't require us to declare dummy methods (though occasionally constructors) | ||
* and make types non-final. | ||
*/ | ||
@GwtCompatible(emulated = true) | ||
abstract class ImmutableMultisetGwtSerializationDependencies<E> extends ImmutableCollection<E> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
guava/src/com/google/common/collect/LinkedHashMultimapGwtSerializationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2016 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.common.collect; | ||
|
||
import com.google.common.annotations.GwtCompatible; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
/** | ||
* A dummy superclass to support GWT serialization of the element types of a {@link | ||
* LinkedHashMultimap}. The GWT supersource for this class contains a field for each type. | ||
* | ||
* <p>For details about this hack, see {@link GwtSerializationDependencies}, which takes the same | ||
* approach but with a subclass rather than a superclass. | ||
* | ||
* <p>TODO(cpovirk): Consider applying this subclass approach to our other types. | ||
*/ | ||
@GwtCompatible(emulated = true) | ||
abstract class LinkedHashMultimapGwtSerializationDependencies<K, V> | ||
extends AbstractSetMultimap<K, V> { | ||
LinkedHashMultimapGwtSerializationDependencies(Map<K, Collection<V>> map) { | ||
super(map); | ||
} | ||
} |