Ticket #248 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

AIOOBE in Util.getLineNumber()

Reported by: stephan Owned by: stephan
Priority: major Milestone: OTDT_1.3.0_M2
Component: compiler Version: 1.2.8
Keywords: Cc: clxris@…

Description

When a role file contains a private static method, the following exception can be observed:

Internal compiler error
java.lang.ArrayIndexOutOfBoundsException: 36
at org.eclipse.jdt.internal.compiler.util.Util.getLineNumber(Util.java:472)
at org.eclipse.jdt.internal.compiler.codegen.CodeStream.recordPositionsFrom(CodeStream.java:6194)
at org.eclipse.jdt.internal.compiler.codegen.CodeStream.recordPositionsFrom(CodeStream.java:5967)
at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:451)
at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:355)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:988)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:1101)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:475)
at org.objectteams.otdt.core.compiler.control.Dependencies.establishUnitState(Dependencies.java:351)
at org.objectteams.otdt.core.compiler.control.Dependencies.ensureState(Dependencies.java:259)
at org.objectteams.otdt.core.compiler.control.Dependencies.ensureState(Dependencies.java:214)
at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:823)
at org.eclipse.jdt.internal.compiler.ProcessTaskManager._OT$run$orig(ProcessTaskManager.java:152)
at org.eclipse.jdt.internal.compiler.ProcessTaskManager._OT$run$chain(ProcessTaskManager.java)
at org.eclipse.jdt.internal.compiler.ProcessTaskManager._OT$run$chain(ProcessTaskManager.java)
at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java)
at java.lang.Thread.run(Unknown Source)

Reported by Christian Laakmann regarding class de.nordakademie.uml2.diagram.clazz.custom.connections.GeneralizationTeam

Change History

Changed 3 years ago by stephan

Problem is wittnessed by new test in r20164.

Analysis: Two separate issues contribute to this bug:

  1. when building a compilation unit using the SourceTypeConverter method declarations have no valid bodyStart/bodyEnd positions (-> (0, -1)).
  2. when creating a team-level bridge method for the private static role method source positions of the role method are used (RoleSplitter.createInterfaceStatements() -> AstConverter.genBridgeForPrivateRoleMethod()), which points to no-where when the role is a role file.

In this particular situation CodeStream.recordPositionsFrom() tries to retrieve a line number beyond the end of lineSeparatorPositions.

  • Item (1) above leads to the CodeStream being initialized with lineNumberStart=1 and lineNumberEnd=1.
  • If the team declaration is shorter (num. characters) than the position of the private static role method within its role file item (2) above leads to a sourcePos (from new AstGenerator(privateRoleMethod.sourceStart...) during genBridgeForPrivateRoleMethod) beyond the range of lineSeparatorPositions.

Note that jacks tests 3.3.20-otjld-inferred-callout-to-field-1s2 cannot reproduce the problem because jacks tests can't reproduce item (1) above.

Changed 3 years ago by stephan

Ups, jacks reference should've been 0.a.1.a-otjld-private-role-method-8.

Changed 3 years ago by stephan

Fixed for 1.3.x in r20165 by avoiding to generated statements when role class is converted.

Pending:

  • backport to 1.2.x
  • running the tests.

Changed 3 years ago by stephan

Backport to 1.2.x is in r20166.

Item (2) above will not be handled here, but in #226.

Changed 3 years ago by stephan

Contrary to initial findings, the bug can also be reproduced in the regular compiler (i.e., not involving the SourceTypeConverter -- see item (1)).

New witness is in 0.a.1.a-otjld-private-role-method-9: this happens if the source range of the role method is within legal source positions of the team, whereas the method body is beyond!

Changed 3 years ago by stephan

Fix for 2nd variant a la 0.a.1.a-otjld-private-role-method-9 is in r20167 (1.2.x) resp. r20170 (trunk).

Changed 3 years ago by stephan

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to OTDT_1.3.0_M2

Tests passed. Closing (for 1.2.9 as well as for 1.3.0M2).

Note: See TracTickets for help on using tickets.