[PLAS-15] lib support groovy/java files loading order may cause imports to fail Created: 29/Jul/20  Updated: 30/Jul/20  Resolved: 30/Jul/20

Status: Done
Project: plastic
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: High
Reporter: Allan Clarke Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Old issue.I thought it was fixed. Basically the lib/ folder files are loaded in reverse alphabetical order, not dependency order. So this may make imports of sibling classes fail if the filenames don't match the dependency order.

The workaround is to make sure the file you are importing is later in sort order than your name. Note that groovy does not insist that class names correspond to file names.

One way to fix this in code is to retry loading. If you have N source files in lib/ you can load them and track the ones that failed. then reload them and track again. if you get no progress, then you bail out of the loop. You would have to execute the loop at most N times.



 Comments   
Comment by Allan Clarke [ 30/Jul/20 ]

There is no bug. The behavior is correct. A user was putting this into the lib folder:
lib/aaa.groovy
package lib
lib/bbb.groovy
package lib
import lib.aaa
class bbb ...
The root of the classpath entry STARTS AT THE LIB FOLDER not its parent.
So the correction is to either put those files into lib/lib/ or to remove the package statement.

Generated at Wed Feb 07 20:36:51 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.