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

Remove dependecy to jdk.unsupported #276

Open
lreto opened this issue Jun 9, 2023 · 6 comments
Open

Remove dependecy to jdk.unsupported #276

lreto opened this issue Jun 9, 2023 · 6 comments

Comments

@lreto
Copy link

lreto commented Jun 9, 2023

Most DTOs in the PubNub SDK don't have a default (empty) constructor. Gson, which is used to serialize and deserialize the DTOs, uses the empty constructor to create instances of the DTO classes. If this is not possible (as it is the case in most classes of the PubNub SDK), sun.misc.Unsafe.allocateInstance() is used for the allocation. This works fine under normal circumstances. However, since we use PubNub on a hardware with limited resources, we try to minimize the JRE size and memory usage. We use a tailored JRE that includes as few modules as possible.
sun.misc.Unsafe.allocateInstance() is part of the jdk.unsupported module, which we normally don't include in our JRE.

It would be helpful for us if empty constructors were added to all DTOs (for example with Lombok's @NoArgsConstructor) so that the PubNub SDK worked without the jdk.unsupported module.

@Swastik-Chakravorty
Copy link

I want to contribute, to add empty constructors to DTOs. But please suggest me which DTO classes are where can I find those. This will be my first contribution if you kindly help.

@lreto
Copy link
Author

lreto commented Jul 10, 2023

The following classes caused troubles in our case:

  • src/main/java/com/pubnub/api/models/SubscriptionItem.java
  • src/main/java/com/pubnub/api/models/consumer/PNBoundedPage.java
  • src/main/java/com/pubnub/api/models/consumer/PNErrorData.java
  • src/main/java/com/pubnub/api/models/consumer/PNPage.java
  • src/main/java/com/pubnub/api/models/consumer/PNPublishResult.java
  • src/main/java/com/pubnub/api/models/consumer/PNStatus.java
  • src/main/java/com/pubnub/api/models/consumer/PNTimeResult.java
  • src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResult.java
  • src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerKeyData.java
  • src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerKeysData.java
  • src/main/java/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.java
  • src/main/java/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.java
  • src/main/java/com/pubnub/api/models/server/DeleteMessagesEnvelope.java
  • src/main/java/com/pubnub/api/models/server/Envelope.java
  • src/main/java/com/pubnub/api/models/server/FetchMessagesEnvelope.java
  • src/main/java/com/pubnub/api/models/server/OriginationMetaData.java
  • src/main/java/com/pubnub/api/models/server/PresenceEnvelope.java
  • src/main/java/com/pubnub/api/models/server/PublishMetaData.java
  • src/main/java/com/pubnub/api/models/server/SubscribeEnvelope.java
  • src/main/java/com/pubnub/api/models/server/SubscribeMessage.java
  • src/main/java/com/pubnub/api/models/server/SubscribeMetadata.java
  • src/main/java/com/pubnub/api/models/server/presence/WhereNowPayload.java

@Swastik-Chakravorty
Copy link

Do you mean to do this only in all files?

public class SubscriptionItem {

private String name;
private Object state;    

public SubscriptionItem();

}

@lreto
Copy link
Author

lreto commented Jul 13, 2023

It would also be possible to do this with a Lombok annotation. This would look something like this

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SubscribeMessage {

@AllArgsConstructor is needed for the @Builder I think.

@kleewho
Copy link
Contributor

kleewho commented Aug 16, 2023

Thank you all. We will look into it

@r1shhh1
Copy link

r1shhh1 commented Nov 25, 2023

Is this issue still open? I would like to work on this if it is.

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

No branches or pull requests

4 participants