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

"Constructor java/lang/StringBuffer(java.lang.CharSequence) is not available at the device!" #135

Closed
jeffque opened this issue Aug 29, 2020 · 1 comment · Fixed by #154
Closed
Assignees
Labels
bug Something isn't working

Comments

@jeffque
Copy link
Collaborator

jeffque commented Aug 29, 2020

"Constructor java/lang/StringBuffer(java.lang.CharSequence) is not available at the device!"

TotalCross 4.3.8 logs this when failing to build com.gitlab.geosales-open-source.totalcross-functional-toolbox:totalcross-functional-toolbox:2.0.3-retrolambda.

Describe the bug

AFAIK, TotalCross should replace all mentions of java.lang.CharSequence with totalcross.lang.String4D. But, in this specific case, this snippet causes TotalCross to not replace te CharSequence with something it knows how to deal with:

	private static class JoiningAcc {
		boolean first = true;
		StringBuilder sb;

		JoiningAcc(CharSequence c) {
			sb = new StringBuilder(c);
		}
	}

The workaround this problem I think it is just to take c.toString(), therefore indeed creating a String with it, and totalcross.lang.StringBuffer4D indeed has the constructor public StringBuffer4D(totalcross.lang.String4D str);

From my previous knowledge, this shoudn't happen.

To Reproduce

Add the following snippet to your code (may be your main class, it makes things easier):

	private static class JoiningAcc {
		boolean first = true;
		StringBuilder sb;

		JoiningAcc(CharSequence c) {
			sb = new StringBuilder(c);
		}
	}

And try to call tc.Deploy your app.

Expected behavior

Compilation success

Screenshots or videos

From my CI logs:

Command line: /builds/SoftSite/geosales/.m2/repository/com/gitlab/geosales-open-source/totalcross-functional-toolbox/totalcross-functional-toolbox/2.0.3-retrolambda/totalcross-functional-toolbox-2.0.3-retrolambda.jar /r <PRIVATE KEY> /t /n totalcross-functional-toolbox-2.0.3-retrolambdaLib.tcz 
TotalCross SDK version 4.3.8.0 running on linux with JDK 1.8
Current folder: /builds/SoftSite/geosales
Etc directory: /builds/SoftSite/geosales/totalcross-cache/4.4.1/TotalCross/etc/
Classpath: [...]
The application was signed with the given registration key.
Next SDK expiration date: 5 September, 2020
Warning: line number information not found. Stack traces at device will be shown incomplete. To fix this, enable debug information when compiling the files. First detected on class br.com.softsite.toolbox.Pair$$Lambda$11
################################# FATAL ERROR ##################################
Class: br/com/softsite/toolbox/stream/Collectors$JoiningAcc
Method: <C>
z.b: Constructor java/lang/StringBuffer(java.lang.CharSequence) is not available at the device! To find the available ones, see the Javadocs for totalcross.lang.StringBuffer class. Be aware that the classes and methods you use from the java.lang package at desktop are automatically transformed by tc.Deploy into the classes and methods available in totalcross.lang. Thus, you must use only the classes and methods described in the javadocs.

Devices:

  • Device: SDK tc.Deploy
  • TotalCross Version: 4.3.8
@jeffque jeffque added the bug Something isn't working label Aug 29, 2020
@jeffque
Copy link
Collaborator Author

jeffque commented Aug 29, 2020

Should mention that I have not tried to reproduce it with newer SDKs versions, but I expect that this misbehaviour remains unchanged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants