2016-06-12 6 views
-1

Я использую Android Studio, и я хочу, чтобы использовать функцииJava Short.ToUnsignedInt Не определено

Byte.toUnsignedInt(...); 
Short.toUnsignedInt(...); 

Но они дают компилятору ошибку, даже если я вижу, что эти функции-члены, которые должны быть в Short и Byte, но он не работает.

У кого-нибудь есть идея?

D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:190: error: cannot find symbol 
       d_U = Short.toUnsignedInt(ind_U[i]) % 255; 
         ^
    symbol: method toUnsignedInt(short) 
    location: class Short 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:191: error: cannot find symbol 
       e_U = Short.toUnsignedInt(ind_U[i]) % 77; 
         ^
    symbol: method toUnsignedInt(short) 
    location: class Short 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:192: error: cannot find symbol 
       a_U = (byte)fSb2_U[(int)d_U]; 
          ^
    symbol: variable fSb2_U 
    location: class AESCrypt 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:193: error: cannot find symbol 
       b_U = (byte)rsB2_U[(int)e_U]; 
          ^
    symbol: variable rsB2_U 
    location: class AESCrypt 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:194: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(a_U) - Byte.toUnsignedInt(b_U)); 
           ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:194: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(a_U) - Byte.toUnsignedInt(b_U)); 
                 ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:194: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(a_U) - Byte.toUnsignedInt(b_U)); 
                        ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:194: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(a_U) - Byte.toUnsignedInt(b_U)); 
                              ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:195: error: cannot find symbol 
       low_U = (byte)(0x0F & Byte.toUnsignedInt(c_U)); 
             ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:196: error: cannot find symbol 
       high_U = (byte)((0xF0 & Byte.toUnsignedInt(b_U)) >> 4); 
              ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:199: error: cannot find symbol 
       d_U = Short.toUnsignedInt(ind_U[k]) % 255; 
         ^
    symbol: method toUnsignedInt(short) 
    location: class Short 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:200: error: cannot find symbol 
       e_U = Short.toUnsignedInt(ind_U[k]) % 89; 
         ^
    symbol: method toUnsignedInt(short) 
    location: class Short 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:201: error: cannot find symbol 
       a_U = (byte)rsB2_U[(int)e_U]; 
          ^
    symbol: variable rsB2_U 
    location: class AESCrypt 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:202: error: cannot find symbol 
       b_U = (byte)rsB2_U[(int)d_U]; 
          ^
    symbol: variable rsB2_U 
    location: class AESCrypt 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:203: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(c_U)); 
           ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:203: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(c_U)); 
                 ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:203: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(c_U)); 
                        ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:204: error: cannot find symbol 
       high_U = (byte)(0x0F & Byte.toUnsignedInt(c_U)); 
             ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:205: error: cannot find symbol 
       low_U = (byte)((0xF0 & Byte.toUnsignedInt(c_U)) >> 4); 
             ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
19 errors 

FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:compileDebugJavaWithJavac'. 
> Compilation failed; see the compiler error output for details. 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

ответ

0

См Javadoc из Short.toUnsignedInt(short x):

С: 1,8

Метод был добавлен в Java 8, поэтому компиляция на старых версиях Java и не будет работать.

Если вы посмотрите на документ Java 7 для Short, вы увидите, что метод не существует.

+0

У меня есть Java 8, но он все еще не работает. Тем не менее, какой странный мир мы живем, где никому в мире от java 1,2,3,4,5,6,7 не нужно было преобразовать короткий в unsigned int до сих пор java 8. Высокая и могучая Java " Боги ", которые разрабатывали язык, должны существовать вне этой вселенной, где они не нуждаются в неподписанных данных, только нам, смертным и риффу, нужны такие мелочи. Мы должны быть благодарны им запомнили, что добавили и вычитали там до того, как мы добрались до java 10. – programmer3

+0

Странная java может делать все эти фантастические вещи, но с неподписанным байтом это слишком много для них. – programmer3

+0

Это не похоже на то, что беззнаковое расширение short to int сложно сделать: 'myInt = myShort & 0xFFFF;'. 'Short.toUnsignedInt()' является просто хорошим методом удобства. – Andreas