Really weird issue. Converted a project to gradle ...
# gradle
s
Really weird issue. Converted a project to gradle from maven (it already had kotlin in it), but now when we're calling a certain constructor we're getting a really weird error. error:
Copy code
error: constructor ThirdPartyFailedResponse in class ThirdPartyFailedResponse cannot be applied to given types;
            ThirdPartyFailedResponse failedResponse = new ThirdPartyFailedResponse(false,
                                                      ^
  required: String,UUID,UUID,UUID
  found: boolean,String,UUID,UUID,UUID
  reason: actual and formal argument lists differ in length
class
Copy code
class ThirdPartyFailedResponse(
        val success: Boolean = false,
        val message: String,
        override val loanTransactionId: UUID,
        override val loanId: UUID?,
        override val serviceOrderId: UUID
) : ThirdPartyResponse
absolutely nothing has changed in the project besides running
gradle init
and then fixing dependencies. I don't see how a dependency could cause an issue like this, it has nothing to do with
@JvmOverloads
, or the like.
f
I guess it's not possible for you to give access to the project? From what is visible all looks good.
m
What happens when you use named arguments?
s
Yeah can't give access :/ and I can't use named args, because it's calling from Java in this spot
m
Could you try:
Copy code
class ThirdPartyFailedResponse @JvmOverloads constructor(
  val ...
)
s
Already tried JvmOverloads, it doesn't work unless we remove the first parameter from the call site
for example with
@JvmOverloads
, this works
Copy code
ThirdPartyFailedResponse failedResponse = new ThirdPartyFailedResponse("Response hasn't received with SLA",
                                                                                   request.getLoanTransactionId(),
                                                                                   request.getLoanId(),
                                                                                   request.getServiceOrderId());
but this doesn't
Copy code
ThirdPartyFailedResponse failedResponse = new ThirdPartyFailedResponse(false, "Response hasn't received with SLA",
                                                                                   request.getLoanTransactionId(),
                                                                                   request.getLoanId(),
                                                                                   request.getServiceOrderId());
m
Can you temporarily reorder the arguments?
s
just for testing?
m
Yes
Like make the boolean the last one
You could also try to add a secondary constructor and not use defaults. But I'm totally guessing here, I have no idea what happens there.
s
same issue.
Copy code
/Users/tyler.thrailkill/Documents/code/backend/thirdparty-integrations/framework/src/main/java/com/promontech/thirdparty/framework/CallbackJob.java:38: error: constructor ThirdPartyFailedResponse in class ThirdPartyFailedResponse cannot be applied to given types;
            ThirdPartyFailedResponse failedResponse = new ThirdPartyFailedResponse(
                                                      ^
  required: String,UUID,UUID,UUID
  found: String,UUID,UUID,UUID,boolean
Copy code
class ThirdPartyFailedResponse @JvmOverloads constructor(
        val message: String,
        override val loanTransactionId: UUID,
        override val loanId: UUID?,
        override val serviceOrderId: UUID,
        val success: Boolean = false
) : ThirdPartyResponse
makes absolutely no sense.
omg. If I remove the default arg I still get the same error!
m
Yeah, I don't know, try this :
Copy code
class ThirdPartyFailedResponse constructor(
        val message: String,
        override val loanTransactionId: UUID,
        override val loanId: UUID?,
        override val serviceOrderId: UUID,
        val success: Boolean = false
) : ThirdPartyResponse {
    constructor(message: String, loanTransactionId: UUID,...) : this(message, loanTransactionId, ..., false) 
}
s
nope didn't work.
wtf
likewtfwtf
m
omg. If I remove the default arg I _still_ get the same error!
Well that doesn't makes any sense. Could you try to delete your build cache (dist folder in the project) and mvn cache (~/.m2/repository)?
s
yeah ha. I'll be back in an hour 🤣
m
Oh, so big 😂 okay mainly I just wanted to re-download the compiler 😉
s
haha we have a beefy connection and I'm ready to go nuclear so no worries.
m
Oh, just remembered that your using grade now, so it's not the dist folder but the build folder in your project
s
I wiped the ~/.gradle/caches folder
build folder is just
clean
m
👍
This happens at compile time, right?
s
yep
compileJava phase
m
Could try to define a function in Kotlin and call that from java, which essentially just calls the constructor?
s
hm.... interesting idea.
let me finish compiling after destroying the cache.
ok same issue after destroying cache
m
🤔
Does it work with an extra function?
s
still working on it.
yes haha wtf.
Copy code
ThirdPartyFailedResponse failedResponse = ThirdPartyFailedResponseKt.callThirdPartyFailedResponseConstructor(false, "Response hasn't received with SLA", request.getLoanTransactionId(),
                                                                                                                         request.getLoanId(),
                                                                                                                         request.getServiceOrderId());
Copy code
class ThirdPartyFailedResponse @JvmOverloads constructor(
    val success: Boolean = false,
    val message: String,
    override val loanTransactionId: UUID,
    override val loanId: UUID?,
    override val serviceOrderId: UUID
) : ThirdPartyResponse

fun callThirdPartyFailedResponseConstructor(
    success: Boolean = false, message: String,
    loanTransactionId: UUID,
    loanId: UUID?,
    serviceOrderId: UUID
) = ThirdPartyFailedResponse(success, message, loanTransactionId, loanId, serviceOrderId)
this makes absolutely no sense... 😭
m
Weird, I think you have a workaround if you need one right now, but for longterm I would recommend going the way of deleting as much stuff as possible and doing this until it works. This way it should be possible to find out why it's not working and also makes it hopefully reproducible.
s
yeah I think we're gonna trash the gradle conversion for now. This was not part of the ticket, I was actually just trying to update spring boot
m
😂 Did you tried the old version with gradle?
s
but to do that we need to either move off the parent pom or go to gradle. i had hoped going to gradle for this project would be easier
yeah it was a straight conversion to gradle, no dependency changes.
then I was going to move to sb2 from there.
we need it because edgeware spring cloud isn't supported.
because we're trying to move apps to spring cloud config.
yak shaving at its finest
m
Well I also migrated to spring cloud config recently and it worked fine. I needed to update spring boot here and there to the latest version, but overall it was fine.
Can you try to use the latest patch version of your spring boot version?
s
I talked to one of the devs because our spring cloud config server is hoxton, and the project from above is edgeware. Edgeware was unable to read arrays properly from cloud server, it tried to read them as xml.
unfortunately, all the maven apps use a parent bom, which is why the conversion to gradle was necessary (well not entirely) to get off of sb2.
the parent bom specifies the spring boot version.
yes it's bad design.
but it's what we've got and are working away from.
m
You said that the constructor would be visible in the byte code, I assume you used the Kotlin->Kotlin Bytecode -> Decompile option. One last thing you could try is to decompile the actual output from gradle from the build/classes folder. Then you would at least know whether it's the java compiler or the Kotlin compiler that's not doing its job.
s
nice idea! yeah I used that option in intellij. hm. what tool would I use for decompiling the output from gradle? haven't done it outside of intellij before, and it just gives me the normal
Copy code
public final class ThirdPartyFailedResponse @kotlin.jvm.JvmOverloads public constructor(success: kotlin.Boolean /* = compiled code */, message: kotlin.String, loanTransactionId: java.util.UUID, loanId: java.util.UUID?, serviceOrderId: java.util.UUID) : com.promontech.common.integrations.message.ThirdPartyResponse {
    public open val loanId: java.util.UUID? /* compiled code */

    public open val loanTransactionId: java.util.UUID /* compiled code */

    public final val message: kotlin.String /* compiled code */

    public open val serviceOrderId: java.util.UUID /* compiled code */

    public final val success: kotlin.Boolean /* compiled code */
}
crap
trying jd-gui
m
s
cool i'll try that next.
yeah it looks fine with jd-gui
Copy code
@Metadata(mv = {1, 1, 16}, bv = {1, 0, 3}, k = 1, d1 = {"\000\036\n\002\030\002\n\002\030\002\n\000\n\002\020\013\n\000\n\002\020\016\n\000\n\002\030\002\n\002\b\f\030\0002\0020\001B3\b\007\022\b\b\002\020\002\032\0020\003\022\006\020\004\032\0020\005\022\006\020\006\032\0020\007\022\b\020\b\032\004\030\0010\007\022\006\020\t\032\0020\007\006\002\020\nR\026\020\b\032\004\030\0010\007X\004\006\b\n\000\032\004\b\013\020\fR\024\020\006\032\0020\007X\004\006\b\n\000\032\004\b\r\020\fR\021\020\004\032\0020\005\006\b\n\000\032\004\b\016\020\017R\024\020\t\032\0020\007X\004\006\b\n\000\032\004\b\020\020\fR\021\020\002\032\0020\003\006\b\n\000\032\004\b\021\020\022\006\023"}, d2 = {"Lcom/promontech/thirdparty/framework/model/ThirdPartyFailedResponse;", "Lcom/promontech/common/integrations/message/ThirdPartyResponse;", "success", "", "message", "", "loanTransactionId", "Ljava/util/UUID;", "loanId", "serviceOrderId", "(ZLjava/lang/String;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)V", "getLoanId", "()Ljava/util/UUID;", "getLoanTransactionId", "getMessage", "()Ljava/lang/String;", "getServiceOrderId", "getSuccess", "()Z", "thirdpary-integration-framework"})
public final class ThirdPartyFailedResponse implements ThirdPartyResponse {
  private final boolean success;
  
  @NotNull
  private final String message;
  
  @NotNull
  private final UUID loanTransactionId;
  
  @Nullable
  private final UUID loanId;
  
  @NotNull
  private final UUID serviceOrderId;
  
  @JvmOverloads
  public ThirdPartyFailedResponse(boolean success, @NotNull String message, @NotNull UUID loanTransactionId, @Nullable UUID loanId, @NotNull UUID serviceOrderId) {
    this.success = success;
    this.message = message;
    this.loanTransactionId = loanTransactionId;
    this.loanId = loanId;
    this.serviceOrderId = serviceOrderId;
  }
  
  public final boolean getSuccess() {
    return this.success;
  }
  
  @NotNull
  public final String getMessage() {
    return this.message;
  }
  
  @NotNull
  public UUID getLoanTransactionId() {
    return this.loanTransactionId;
  }
  
  @Nullable
  public UUID getLoanId() {
    return this.loanId;
  }
  
  @NotNull
  public UUID getServiceOrderId() {
    return this.serviceOrderId;
  }
  
  @JvmOverloads
  public ThirdPartyFailedResponse(@NotNull String message, @NotNull UUID loanTransactionId, @Nullable UUID loanId, @NotNull UUID serviceOrderId) {
    this(false, message, loanTransactionId, loanId, serviceOrderId, 1, null);
  }
}
m
What's that 1 and null down there in the other constructor 🤔😂
s
lol wut...
um... no clue haha
it's calling the parent class which implements Serializable .
Copy code
interface ThirdPartyResponse : Serializable {
    val loanTransactionId: UUID
    val loanId: UUID?
    val serviceOrderId: UUID
}