Skip to content

[ComplianceTests] Malformed compliance tests#861

Closed
yisraelU wants to merge 2 commits into
series/0.17from
malformed-compliance-tests
Closed

[ComplianceTests] Malformed compliance tests#861
yisraelU wants to merge 2 commits into
series/0.17from
malformed-compliance-tests

Conversation

@yisraelU

Copy link
Copy Markdown
Contributor

This pr adds the last component of the protocol compliance tests as defined by Smithy
https://smithy.io/2.0/additional-specs/http-protocol-compliance-tests.html#httpmalformedrequesttests

# Conflicts:
#	modules/compliance-tests/src/smithy4s/compliancetests/ComplianceTest.scala
#	modules/compliance-tests/src/smithy4s/compliancetests/internals/ClientHttpComplianceTestCase.scala
#	modules/compliance-tests/src/smithy4s/compliancetests/internals/ServerHttpComplianceTestCase.scala
#	modules/transformers/src/SimpleRestJsonProtocolTransformer.scala
@yisraelU

Copy link
Copy Markdown
Contributor Author

[error] [http4sJS3] Referring to non-existent class software.amazon.smithy.utils.SimpleCodeWriter
@Baccata I dont know too much about scalajs , is this because of the nio utils included in this package
https://github.com/awslabs/smithy/blob/main/smithy-utils/src/main/java/software/amazon/smithy/utils/IoUtils.java

@kubukoz

kubukoz commented Jun 4, 2025

Copy link
Copy Markdown
Member

way to dig up an old issue, I know...

the problem is that you're using a Java class: import software.amazon.smithy.utils.SimpleCodeWriter - can't do this in a cross-compiled Scala module. We're gonna have to rewrite the implementation in terms of something written 100% in Scala.

@yisraelU

yisraelU commented Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

@kubukoz can you explain more.
Why would using a java class prevent cross compilation ? All Scala code calls java code.
Do you mean because it is being called directly rather through a layer of indirection. ?

@kubukoz

kubukoz commented Jun 4, 2025

Copy link
Copy Markdown
Member

All Scala code calls java code.

Sort of. The Scala standard library does call out to some Java classes/methods, but because Java code can't be transpiled to JS/Native, these classes/methods have to be reimplemented in Scala - you can find that e.g.

Why would using a java class prevent cross compilation?

just because Scala.js and Scala Native's compiler plugins can only output the appropriate SJSIR / NIR files from Scala files. These *IR files are needed for further processing, e.g. linking and generating output JS/LLVM.

to sum up, you can't use any Java symbol on JS/Native, unless a Scala implementation is also provided.

This is why we have platform-specific files in the first place - sometimes you can't / don't want to reimplement the Java, so:

  • in Java-specific sources you'll use Java libraries,
  • in JS-specific sources you'll use interop with JavaScript libraries,
  • in Native-specific sources you'll use interop with native libraries.

@kubukoz

kubukoz commented Jun 4, 2025

Copy link
Copy Markdown
Member

There was a project that provided a Java frontend for Scala.js, which would allow using Java code on the JS side here, but it seems to have been forgotten: https://github.com/arthanzel/scalajs-jfe

@yisraelU

Copy link
Copy Markdown
Contributor Author

closed in favor of #1918

@yisraelU yisraelU closed this Apr 16, 2026
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.

2 participants