-
Notifications
You must be signed in to change notification settings - Fork 193
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
ArrayIndexOutOfBoundsException - Type Inference #826
Comments
Do you have any stack frames for the ArrayIndexOutOfBoundsException? Where were you engaging content assist? |
This happens if I just type the name of the class and then a period. Once it starts, autocomplete starts breaking for everything in the script. I'm just seeing the error in the workspace log so I'm not sure how to get a stack frame. |
Okay, can you exit your eclipse, open eclipse.ini and add "-XX:-OmitStackTraceInFastThrow" as the last line? This will disable "fast throw" mode which can leave off stack trace information for common exceptions. Are you typing "SchemaBuilder." and then content assist opens? |
Yes I'm typing "SchemaBuilder." and then content assist opens. |
So the LookupEnvironment/TypeSystem is being reset. And so the types array is reduced in length back to 256 each time. The return type of SchemaBuilder.array() is given the type id 281 and so that is OOB for a length 256 array. I'm investigating if the reset is by design or if the source of the issue is performing this reset with active type bindings out there. |
Your groovy script is located within src/test/resources, so the Maven configurator did not get triggered to add the Groovy nature to your project. Then when you open a groovy source in the groovy editor, it runs through this code in CompilationUnitProblemFinder: // GROOVY add
boolean reset = true;
// GROOVY end
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement.getJavaProject(), unitElement));
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
compilerOptions.ignoreMethodBodies = ignoreMethodBodies;
// GROOVY add
// options fetched prior to building problem finder then configured based on project
CompilerUtils.configureOptionsBasedOnNature(compilerOptions, project);
if (!creatingAST) {
compilerOptions.groovyCompilerConfigScript = null;
}
if (compilerOptions.buildGroovyFiles == 2) {
reset = false;
}
// GROOVY end
...
} finally {
...
// GROOVY edit -- reset() can cause OOB exceptions in TypeSystem
//if (problemFinder != null && !creatingAST)
if (problemFinder != null && !creatingAST && reset)
// GROOVY end
problemFinder.lookupEnvironment.reset();
} The reset flag is set to false when buildGroovyFiles is "yes". In your project, it is "no" and so the lookup environment and type system are reset. You can right-click on your project and select Configure > Convert to Groovy Project to add the nature and stop the OOB exceptions. I am working on a better overall solution, but you can stop the exceptions immediately with the workaround. |
Ready to test |
Installed the latest snapshot and the errors are gone. |
This looks similar to #808 but when trying to auto complete org.apache.avro.SchemaBuilder you get the following exception. I'm running Eclipse 4.10 latest and Eclipse Groovy Development Tools 3.3.0.xx-201902260000-e48. You can take a look at the groovy script at shawnweeks/nifi-groovy-testing on github.
The text was updated successfully, but these errors were encountered: