You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When passing an array to a method, the original array isn't manipulated. Seems like the copy of an array is used instead.
To reproduce
Code using SecureRandom#nextBytes method:
command /test:
trigger:
# Tried with different algorithms and with SecureRandom.getInstanceStrong(), same issue
set {_rng} to SecureRandom.getInstance("SHA1PRNG", "SUN")
set {_salt} to new byte[4]
send {_salt}
{_rng}.nextBytes({_salt})
send {_salt}
Expected behavior
Both examples above should result in arrays being filled with numbers (random numbers in the first example). I ran analogous code in Java (same JDK version) and it worked flawlessly.
To confirm the issue, one person (to whom I am grateful) created a small test JAR with the following code:
public class Main {
private static final int[] arr = new int[2];
public static int[] get() {
return arr;
}
}
and a script with the code below:
command /test:
trigger:
set {_array} to Main.get()
broadcast {_array}
Arrays.fill({_array}, 5)
broadcast Main.get()
Result:
[22:34:59 INFO]: [0, 0]
[22:34:59 INFO]: [0, 0]
Screenshots
None.
Server information
skript-reflect: 2.5.1
Skript: 2.9.1
Paper: 1.21-111
Minecraft: 1.21
Java: 22.0.2
OS: Windows 10
Additional context
I stumbled upon this issue when I was fiddling with SecureRandom class to generate salt for hashing passwords.
The text was updated successfully, but these errors were encountered:
Describe the bug
When passing an array to a method, the original array isn't manipulated. Seems like the copy of an array is used instead.
To reproduce
Code using SecureRandom#nextBytes method:
Result:
Code using Arrays.fill method:
Result:
Expected behavior
Both examples above should result in arrays being filled with numbers (random numbers in the first example). I ran analogous code in Java (same JDK version) and it worked flawlessly.
To confirm the issue, one person (to whom I am grateful) created a small test JAR with the following code:
and a script with the code below:
Result:
Screenshots
None.
Server information
Additional context
I stumbled upon this issue when I was fiddling with SecureRandom class to generate salt for hashing passwords.
The text was updated successfully, but these errors were encountered: