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

Make java code jdk11 compliant #432

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions erpc_java/deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

<properties>
<!-- Java version configuration -->
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Plugins versions -->
Expand Down Expand Up @@ -192,4 +192,4 @@
</plugins>
</build>

</project>
</project>
6 changes: 3 additions & 3 deletions erpc_java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

<properties>
<!-- Java version configuration -->
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Plugins versions -->
Expand Down Expand Up @@ -126,4 +126,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,80 @@

package io.github.embeddedrpc.erpc.auxiliary;

import java.util.Objects;

public final class MessageInfo {
private final MessageType type;
private final int service;
private final int request;
private final int sequence;

/**
* Record storing information about message.
* Class storing information about message.
*
* @param type Message type
* @param service Service identification
* @param request Request identification
* @param sequence Sequence number
*/
public record MessageInfo(
MessageType type,
int service,
int request,
int sequence) {
public MessageInfo(MessageType type, int service, int request, int sequence) {
this.type = type;
this.service = service;
this.request = request;
this.sequence = sequence;
}

/**
* Get message type.
*
* @return type
*/
public MessageType type() {
return type;
}

/**
* Get message service.
*
* @return service
*/
public int service() {
return service;
}

/**
* Get message request.
*
* @return request
*/
public int request() {
return request;
}


/**
* Get message sequence.
*
* @return sequence
*/
public int sequence() {
return sequence;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof MessageInfo)) {
return false;
}
MessageInfo that = (MessageInfo) o;
return service == that.service && request == that.request && sequence == that.sequence && type == that.type;
}

@Override
public int hashCode() {
return Objects.hash(type, service, request, sequence);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ public int getValue() {
* @return Corresponding MessageType
*/
public static MessageType getMessageType(int value) {
return switch (value) {
case 0 -> kInvocationMessage;
case 1 -> kOnewayMessage;
case 2 -> kReplyMessage;
case 3 -> kNotificationMessage;
default -> throw new RuntimeException("Invalid MessageType " + value);
};
switch (value) {
case 0:
return kInvocationMessage;
case 1:
return kOnewayMessage;
case 2:
return kReplyMessage;
case 3:
return kNotificationMessage;
default:
throw new RuntimeException("Invalid MessageType " + value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,82 @@
import io.github.embeddedrpc.erpc.codec.Codec;
import groovyjarjarantlr.ByteBuffer;

import java.util.Objects;

public final class RequestContext {
private final int sequence;
private final ByteBuffer message;
private final Codec codec;
private final Boolean isOneWay;

/**
* Record storing request context.
* Class storing request context.
*
* @param sequence Sequence number
* @param message Message to be sent
* @param codec Codec used to store send and received message
* @param isOneWay Request direction
*/
public record RequestContext(int sequence, ByteBuffer message, Codec codec, Boolean isOneWay) {
public RequestContext(int sequence, ByteBuffer message, Codec codec, Boolean isOneWay) {
this.sequence = sequence;
this.message = message;
this.codec = codec;
this.isOneWay = isOneWay;
}

/**
* Get request context sequence.
*
* @return sequence
*/
public int sequence() {
return sequence;
}

/**
* Get request context message.
*
* @return message
*/
public ByteBuffer message() {
return message;
}

/**
* Get request context codec.
*
* @return codec
*/
public Codec codec() {
return codec;
}

/**
* is request context oneWay.
*
* @return isOneWay
*/
public boolean isOneWay() {
return isOneWay;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof RequestContext)) {
return false;
}
RequestContext that = (RequestContext) o;
return sequence == that.sequence
&& Objects.equals(message, that.message)
&& Objects.equals(codec, that.codec)
&& Objects.equals(isOneWay, that.isOneWay);
}

@Override
public int hashCode() {
return Objects.hash(sequence, message, codec, isOneWay);
}
}