Java actions broken after Mendix 10 update?

0
Good afternoon all!   I've recently updated my Mendix application to Mendix 10.6.1 and am having issues with some Java actions. It gives me errors when I try to compile and run my application, and the notes are: Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. I'm pretty sure the issue is with the Java actions containing deprecated actions, but I'm not sure how to fix this. When I go into the .java files I can see comments flagging some parts of the code as deprecated (as shown below) public class GetFileFromZip extends CustomJavaAction<IMendixObject> { /** @deprecated use ZipFile.getMendixObject() instead. */ @java.lang.Deprecated(forRemoval = true) private final IMendixObject __ZipFile; private final system.proxies.FileDocument ZipFile; private final java.lang.String FilePathEndsWith; private final java.lang.Boolean CaseSensitive; but I'm not sure where I should be making changes or how to make sure my code still maintains its functionality.  I notice there is a warning that says // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. The deprecated code is outside of these bounds so will it be lost when I redo the project? How do I make sure that doesn't happen?   Is there a way to automatically update the code so it is compatible with the current version of Mendix? Any advice would be appreciated.   Many thanks, Hartley
asked
2 answers
1

I have solved this now. It appears that the auto generated code has changed slightly between Mendix 9 and Mendix 10. I looked back at the code from an old branch that I haven't updated to Mendix 10 yet and found this difference.

 

Mendix 9:

public class GetFileFromZip extends CustomJavaAction<IMendixObject>
{
	private IMendixObject __ZipFile;
	private system.proxies.FileDocument ZipFile;
	private java.lang.String FilePathEndsWith;
	private java.lang.Boolean CaseSensitive;

Same code but Mendix 10:

public class GetFileFromZip extends CustomJavaAction<IMendixObject>
{
	/** @deprecated use ZipFile.getMendixObject() instead. */
	@java.lang.Deprecated(forRemoval = true)
	private final IMendixObject __ZipFile;
	private final system.proxies.FileDocument ZipFile;
	private final java.lang.String FilePathEndsWith;
	private final java.lang.Boolean CaseSensitive;

Note the addition of "final". This means that later on in my code when I try the line:

FilePathEndsWith = FilePathEndsWith.toLowerCase();

I get an error as the variable is meant to be "final" and therefore cannot change. 

 

I understand the error now and hope that this helps anyone struggling with similar errors. It can be tricky to spot that the auto generated parts of the code have changed. 

answered
0

Hi, you should use the Parameters on the java action general tab to try pass those classes/entities so that it will not be removed.

answered