Buggy code:
public final class EasyLegacyMotorController extends I2cControllerPortDeviceImpl implements DcMotorController , Engagable , IOpModeStateTransitionEvents , IThunkWrapper < DcMotorController > , VoltageSensor { public final String LOGGING_TAG = SynchronousOpMode . LOGGING_TAG ; private static final int iRegWindowFirst = 64 ; private static final int iRegWindowMax = 86 ; private static final byte [ ] mpMotorRegMotorPower = new byte [ ] { ( ( byte ) ( - 1 ) ) , ( ( byte ) ( 69 ) ) , ( ( byte ) ( 70 ) ) } ; private static final byte [ ] mpMotorRegMotorMode = new byte [ ] { ( ( byte ) ( - 1 ) ) , ( ( byte ) ( 68 ) ) , ( ( byte ) ( 71 ) ) } ; private static final byte [ ] mpMotorRegTargetEncoderValue = new byte [ ] { ( ( byte ) ( - 1 ) ) , ( ( byte ) ( 64 ) ) , ( ( byte ) ( 72 ) ) } ; private static final byte [ ] mpMotorRegCurrentEncoderValue = new byte [ ] { ( ( byte ) ( - 1 ) ) , ( ( byte ) ( 76 ) ) , ( ( byte ) ( 80 ) ) } ; private static final int motorFirst = 1 ; private static final int motorLast = 2 ; private static final byte cbEncoder = 4 ; private static final byte bPowerBrake = 0 ; private static final byte bPowerFloat = - 128 ; private static final byte bPowerMax = 100 ; private static final byte bPowerMin = - 100 ; private static final double powerMin = - 1.0 ; private static final double powerMax = 1.0 ; private final OpMode context ; private final II2cDeviceClient i2cDeviceClient ; private final DcMotorController target ; I2cDeviceReplacementHelper < DcMotorController > helper ; private DcMotor motor1 ; private DcMotor motor2 ; private EasyLegacyMotorController ( OpMode context , II2cDeviceClient ii2cDeviceClient , DcMotorController target , I2cController controller , int targetPort ) { } public static DcMotorController create ( OpMode context , DcMotorController target , DcMotor motor1 , DcMotor motor2 ) { } private void setMotors ( DcMotor motor1 , DcMotor motor2 ) { } private void usurpDevices ( ) { } private void deusurpDevices ( ) { } private static final String swerveVoltageSensorName = "<seq2seq4repair_space>|Swerve|Legacy|VoltageSensor|<seq2seq4repair_space>" ; private void registerVoltageSensor ( ) { } private void unregisterVoltageSensor ( ) { } public synchronized void engage ( ) { } public synchronized boolean isEngaged ( ) { } public synchronized void disengage ( ) { } @ Override public DcMotorController getWrappedTarget ( ) { } @ Override public double getVoltage ( ) { } @ Override public String getDeviceName ( ) { } @ Override public String getConnectionInfo ( ) { } @ Override public int getVersion ( ) { } @ Override public synchronized void close ( ) { } @ Override public synchronized boolean onUserOpModeStop ( ) { } @ Override public synchronized boolean onRobotShutdown ( ) { } private boolean isArmed ( ) { } @ Override public synchronized void setMotorControllerDeviceMode ( DcMotorController . DeviceMode port ) { } @ Override public synchronized DeviceMode getMotorControllerDeviceMode ( ) { } @ Override public synchronized void setMotorChannelMode ( int motor , DcMotorController . RunMode mode ) { this . validateMotor ( motor ) ; byte bNewMode = EasyLegacyMotorController . modeToByte ( mode ) ; this . write8 ( EasyLegacyMotorController . mpMotorRegMotorMode [ motor ] , bNewMode ) ; for ( ; ; ) { if ( ! ( this . isArmed ( ) ) ) break ; byte bCurrentMode = this . i2cDeviceClient . read8 ( EasyLegacyMotorController . mpMotorRegMotorMode [ motor ] ) ; if ( bCurrentMode == bNewMode ) break ; Thread . yield ( ) ; } if ( mode == ( RunMode . RESET_ENCODERS ) ) { <START_BUG> while ( ( this . getMotorTargetPosition ( motor ) ) != 0 ) { <END_BUG> if ( ! ( this . isArmed ( ) ) ) break ; Thread . yield ( ) ; } } else if ( mode == ( RunMode . RUN_TO_POSITION ) ) { double power = getMotorPower ( motor ) ; if ( power < 0 ) setMotorPower ( motor , Math . abs ( power ) ) ; } } @ Override public synchronized RunMode getMotorChannelMode ( int motor ) { } static final int busyThreshold = 5 ; @ Override public synchronized boolean isBusy ( int motor ) { } @ Override public synchronized void setMotorPower ( int motor , double power ) { } @ Override public synchronized double getMotorPower ( int motor ) { } @ Override public synchronized void setMotorPowerFloat ( int motor ) { } @ Override public synchronized boolean getMotorPowerFloat ( int motor ) { } @ Override public synchronized void setMotorTargetPosition ( int motor , int position ) { } @ Override public synchronized int getMotorTargetPosition ( int motor ) { } @ Override public synchronized int getMotorCurrentPosition ( int motor ) { } private void write8 ( int ireg , byte data ) { } private void write ( int ireg , byte [ ] data ) { } private void initPID ( ) { } private void floatMotors ( ) { } private void stopMotors ( ) { } private void validateMotor ( int motor ) { } public static byte modeToByte ( DcMotorController . RunMode mode ) { } public static RunMode modeFromByte ( byte b ) { } }

Fix:
while ( ( this . getMotorCurrentPosition ( motor ) ) != 0 ) {