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

Type casting for return type is not correct. Error CS0234: The type or namespace name 'Lang' does not exist in the namespace #5894

Closed
akalghatgi opened this issue Apr 30, 2021 · 2 comments
Assignees
Labels
Area: Bindings Issues in Java Library Binding projects.

Comments

@akalghatgi
Copy link

akalghatgi commented Apr 30, 2021

Steps to Reproduce

  1. Creating Binding Project
  2. Add koin-core-2.1.0.jar to jar folder and set the Build Action to "EmbeddedJar"
  3. Build
  4. Throws errors.

Expected Behavior

Should build and should create binding for each class

Actual Behavior

Throws multiple error and Binding fails

Version Information

@akalghatgi akalghatgi added Area: Bindings Issues in Java Library Binding projects. needs-triage Issues that need to be assigned. labels Apr 30, 2021
@jpobst
Copy link
Contributor

jpobst commented Apr 30, 2021

Ugh, they have a package called org.koin.java which gets translated to the C# namespace Org.Koin.Java. When we try to cast things to Java.Lang.Object it is trying to resolve it as Org.Koin.Java.Lang.Object which is incorrect.

The easiest fix is to rename that package to something else using metadata, like this:

<attr path="/api/package[@name='org.koin.java']" name="managedName">Koin</attr>

@jpobst jpobst removed the needs-triage Issues that need to be assigned. label Apr 30, 2021
@akalghatgi
Copy link
Author

Hi @jpobst,
Thanks a lot... renaming has the solved the issue for me... :-)

Regards,
Amit

jonpryor pushed a commit to dotnet/java-interop that referenced this issue May 13, 2021
…838)

Context: dotnet/android#5894

When creating the cast from a generic type parameter (which is
currently always `Java.Lang.Object`), `global::` is not prepended to
the type cast:  

	return (Java.Lang.Object) global::Java.Lang.Object.GetObject<global::Java.Lang.Object> (__rm.Handle, JniHandleOwnership.TransferLocalRef);

This creates a compilation error if the bound type is in a namespace
that ends in `.Java`, such as `MyProduct.Java`.

	Error CS0234: The type or namespace name 'Lang' does not exist in the namespace 'MyProduct.Java'.

Fix this by ensuring the cast output goes through our standard type
formatting method which adds `global::` when needed.
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue May 20, 2021
Fixes: dotnet/java-interop#835
Fixes: dotnet#5921

Context: dotnet#5894

Changes: http://github.com/xamarin/Java.Interop/compare/12e670a8560f69581d3a3adf0a9d91e8ce8c9afa...2573dc8c84fd4eb68e75bcae73912c26f4942356

  * dotnet/java-interop@2573dc8c: [Java.Interop.Tools.*] IMetadataResolver not TypeDefinitionCache (dotnet#842)
  * dotnet/java-interop@412e974b: Revert "[generator] Disable [SupportedOSPlatform] until .NET 5/6. (dotnet#781)" (dotnet#841)
  * dotnet/java-interop@23baf0bc: [Java.Interop] Fix NRT warnings introduced by targeting 'net6.0' (dotnet#840)
  * dotnet/java-interop@131c1496: [generator] Fix NRE from return type not consistently set (dotnet#834)
  * dotnet/java-interop@100fffc1: [generator] Ensure "global::" is prepended to generic return casts. (dotnet#838)
  * dotnet/java-interop@9b89e90e: [generator] Ignore types without names (dotnet#837)
  * dotnet/java-interop@0e01fb5d: [Java.Interop.Tools.JavaSource] Merge @return block values (dotnet#836)
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue May 20, 2021
Fixes: dotnet/java-interop#835
Fixes: dotnet#5921

Context: dotnet#5894

Changes: http://github.com/xamarin/Java.Interop/compare/12e670a8560f69581d3a3adf0a9d91e8ce8c9afa...2573dc8c84fd4eb68e75bcae73912c26f4942356

  * dotnet/java-interop@2573dc8c: [Java.Interop.Tools.*] IMetadataResolver not TypeDefinitionCache (dotnet#842)
  * dotnet/java-interop@412e974b: Revert "[generator] Disable [SupportedOSPlatform] until .NET 5/6. (dotnet#781)" (dotnet#841)
  * dotnet/java-interop@23baf0bc: [Java.Interop] Fix NRT warnings introduced by targeting 'net6.0' (dotnet#840)
  * dotnet/java-interop@131c1496: [generator] Fix NRE from return type not consistently set (dotnet#834)
  * dotnet/java-interop@100fffc1: [generator] Ensure "global::" is prepended to generic return casts. (dotnet#838)
  * dotnet/java-interop@9b89e90e: [generator] Ignore types without names (dotnet#837)
  * dotnet/java-interop@0e01fb5d: [Java.Interop.Tools.JavaSource] Merge @return block values (dotnet#836)
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue May 21, 2021
Fixes: dotnet/java-interop#835
Fixes: dotnet#5921

Context: dotnet#5894

Changes: http://github.com/xamarin/Java.Interop/compare/12e670a8560f69581d3a3adf0a9d91e8ce8c9afa...a5ed8919fb2ec894cb8144e51ae7c29b4811ee2a

  * dotnet/java-interop@a5ed8919: [Java.Interop.Tools.Cecil] Fix the xamarin-android build
  * dotnet/java-interop@2573dc8c: [Java.Interop.Tools.*] IMetadataResolver not TypeDefinitionCache (dotnet#842)
  * dotnet/java-interop@412e974b: Revert "[generator] Disable [SupportedOSPlatform] until .NET 5/6. (dotnet#781)" (dotnet#841)
  * dotnet/java-interop@23baf0bc: [Java.Interop] Fix NRT warnings introduced by targeting 'net6.0' (dotnet#840)
  * dotnet/java-interop@131c1496: [generator] Fix NRE from return type not consistently set (dotnet#834)
  * dotnet/java-interop@100fffc1: [generator] Ensure "global::" is prepended to generic return casts. (dotnet#838)
  * dotnet/java-interop@9b89e90e: [generator] Ignore types without names (dotnet#837)
  * dotnet/java-interop@0e01fb5d: [Java.Interop.Tools.JavaSource] Merge @return block values (dotnet#836)
jonpryor added a commit that referenced this issue May 23, 2021
Fixes: dotnet/java-interop#835
Fixes: #5921

Context: #5894

Changes: http://github.com/xamarin/Java.Interop/compare/12e670a8560f69581d3a3adf0a9d91e8ce8c9afa...a5ed8919fb2ec894cb8144e51ae7c29b4811ee2a

  * dotnet/java-interop@a5ed8919: [Java.Interop.Tools.Cecil] Fix the xamarin-android build
  * dotnet/java-interop@2573dc8c: [Java.Interop.Tools.*] IMetadataResolver not TypeDefinitionCache (#842)
  * dotnet/java-interop@412e974b: Revert "[generator] Disable [SupportedOSPlatform] until .NET 5/6. (#781)" (#841)
  * dotnet/java-interop@23baf0bc: [Java.Interop] Fix NRT warnings introduced by targeting 'net6.0' (#840)
  * dotnet/java-interop@131c1496: [generator] Fix NRE from return type not consistently set (#834)
  * dotnet/java-interop@100fffc1: [generator] Ensure "global::" is prepended to generic return casts. (#838)
  * dotnet/java-interop@9b89e90e: [generator] Ignore types without names (#837)
  * dotnet/java-interop@0e01fb5d: [Java.Interop.Tools.JavaSource] Merge @return block values (#836)
@ghost ghost locked as resolved and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: Bindings Issues in Java Library Binding projects.
Projects
None yet
Development

No branches or pull requests

2 participants