« first day (3066 days earlier)      last day (2099 days later) » 

00:00
As the trials of life continue to take their toll, remember that there is always a future in Computer Maintenance. -- National Lampoon, "Deteriorata" (source)
 
6 hours later…
05:49
farts
06:44
faints
sigh
07:08
@OakBot jeez what did you eat?
@SurajRao Type /help to see all my commands.
07:57
can you prevent multiple login for the same user in spring RestFul using spring security
@Monis Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D
thanks @OakBot
@Monis Type /help to see all my commands.
/help
My commands are also listed here: github.com/JavaChat/OakBot/wiki/Commands
08:10
how can i print result only once after recursion ends in this method?
1 message moved to friendly bin
Please use a paste site for long code snippets and stacktraces.
08:35
sessionManagement()
    .maximumSessions(1)
    .maxSessionsPreventsLogin(true);
Seems to be the key to success.
https://stackoverflow.com/a/53519461/6707985
https://stackoverflow.com/q/37704993/6707985
Are also resources.
08:51
@geisterfurz007 No thanks, I'm fine with Java 8
12 > 8
So naturally it must be better.
Notice: The SO 2019 Moderator Election is currently in the election phase. Voting ends in 3 days.
09:11
This is a NAA right?
I guess so yah.
Let me correct myself:
This is not an Android room. Please take your question to a room dedicated to Android. If you came here because you don't have access to the Android room, remember that there are other rooms too with Android as the topic.
:P
@SurajRao Maybe what he wanted to say was "The above code failed for me with <stacktrace> but this worked for me" because the code does not contain the failing line at least.
Or it's internal of the method he used; dunno.
right thanks... flagged
Hello, if I have Integer i= new Integer(8); is i primitive or reference variable? I understand i to be pointing to an Object of integer type. Does that not make it reference variable since it is pointing to an Object?
 
1 hour later…
10:34
@geisterfurz007 but is this also applicable for Spring RestFul , cause there are no sessions in my service it being REST and all
@JWizard Easy enough to check: make another int, go k = i;, check for reference equality
11:24
JUST how can I get a simple executable for a jfx11 (with modules) app? I'm following this tutorial openjfx.io/openjfx-docs/#IDE-Eclipse
but I'm getting this error:
λ jlink --module-path "%PATH_TO_FX_MODS%;target\hellofx-1.0-SNAPSHOT.jar" --add-modules=hellofx --output jre
Error: Module javafx.fxml not found, required by hellofx
11:58
0
Q: How to create a standalone application using JavaFX 11 (Modular)?

Zeta.InvestigatorI'm following the tutorial here and using openjdk 11.0.2 and javafx-sdk-11.0.2. I've imported the maven project in Eclipse. The project actually compiles and packages just fine. It also created the jar file in /target directory. The problem is, I want to export a single executable for my applica...

On the first night of sleeping in a new place, one hemisphere of our brain remains more active than the other during sleep. Scientists believe this "vigilant mode" allows us to respond more quickly to unfamiliar, potentially danger-signaling sounds. (source)
 
2 hours later…
14:24
Pf. More active than 0 activity isn't that crazy, is it?
Some people rang the door at my parents place when I stayed there (3 am or something) and I didn't hear it :D
15:06
Hi, does anyone know an example where HashMaps don't ensure iteration order in their keys? Meaning for {1=2,2=3,3=4}, if we iterate the entrySet() or keySet(), we are not guaranteed to get the order of 1,2,3 according to them. However, I cannot find a time where the order isn't ensured.

if the order can be changed, and instead I use LinkedHashMap which somewhat ensures that order, if I'm going to iterate via keySet() and entrySet() again, how does Java ensure that these methods also turn out ordered?
(see full text)
the order is based on the hashcode of the key
but it is modulo'ed by the size of the bucket
the size of the bucket is preferably ~120% of the size of the elements (while keeping it 2^n)
iirc, the default size is 16
and hashcodes of ints are their value
so, 17 would be before 2
val map = Map.of(
	2, "2",
	17, "17"
);

map.forEach((key, value) -> System.out.println(value));
prints:
17
2
it appears the order changes between runs even
15:27
@Wietlol hmm cool, it's my first time seeing this behaviour since you use the basic Map. However, I haven't seen this unexpected order from HashMaps
then try using a hashmap? put 2 and 17 as keys and look at the order
"basic Map" doesnt really exist
its an interface so there are no instances of it
Map.of() returns an instance of java.util.ImmutableCollections.MapN
ok my bad, so only LinkedHashMap and whatever iteration methods that follow allows for the order to be predictable
only maps that have an explicit order in them
LinkedHashMap is one of them
any implementation of java.util.NavigableMap are too
TreeMap, MultiMap, SubMap for example
do you have a particular code that can cause ConcurrentModificationException when iterating through HashMaps?
I dont think that is quite difficult tho
15:34
for some reason I ran the code I found online, I don't get that error
public static void main(String[] args) throws IOException
{
	val map = new HashMap<Integer, Integer>();

	map.put(0, 0);

	map.forEach((key, value) -> map.put(key + 1, value + 1));
}
this throws the ConcurrentModificationException
can you share the code ?
I think the difference here is you iterated by entrySet() while the example used keySet, hence the map is not directly iterated
Is my inference correct?
not really, the difference is that you completed iterating before you add new items
try with
map.put(0, 0);
map.put(1, 1);
and
if (key == 0) map.put(2, 2);
but it is really bad to change a collection while you iterate over it
I would highly recommend you to not do so
I'm doing this just to understand how a Hash works, so that I know the cause of the Exceptions and could debug them accordingly
I would definitely try to filter out the bad practices, that of which I haven't shortlisted for working with Hashes
15:50
a hash is just a binary value which can be used to quickly check if values are different (it only guarantees that values are different, not that values are the same)
a map is a key-value collection where the key is unique and can be used to quickly find the value based on the key
a hash map does this by using a hash of the key and storing that in an array
but if you want to avoid errors, dont mutate collections
then you can rarely go wrong
Is there anything that could go wrong with this code in terms of errors? This is an assignment code that has passed all runtime limits and provided test cases in terms of correctness.

Just want to check how many bad practices are here for this one, and whether there's a neat way of removing the bad practices while still keeping to the time and memory limits
16:05
I wouldnt write it like that, but it looks good
I also tried testing the unpredicted order behaviour once again. It seems that this prints in order, different from the example just now.

https://paste.ofcode.org/t8GakzKBkhJ2kz88LtRePh
@Wietlol Haha I think you meant good in terms of conciseness?
good in terms of nothing weird is going on
alright noted
I will try harder Hash problems of my own to see if anything crops up then
@Wietlol Why does the latest "paste" code I posted show correct order though? Is it a coincidence or did I do something very differently?
define "correct"
16:18
HashMap is unordered, there is no "correct"
so its merely a coincidence now that it prints the way I want it to print?
I tried it like 5 times, the order consistently printed the way I want it
if you want it to print in a certain order, then you need to use an ordered collection
Is there a reason why my code earlier wouldn't produce any ConcurrentModificationException while changing the TreeMap to be returned?

https://paste.ofcode.org/JkjGkpuYWvm766Gcep7SL9
What a fortunate coincidence 😀 We got a Wietlol here (:
@PrashinJeevaganth because you dont iterate over the tree map
@geisterfurz007 ohai
16:34
Did you use kotlin-react-router-dom?
using it now
@Wietlol is iterating the keySet() not considered iterating the tree map? Now I'm confused whether an exception could happen depending on the way of iteration rather than the stage of iteration
@PrashinJeevaganth oh, you are not mutating the structure
there are two forms of mutable collections
value-mutable collections and structure-mutable collections
value-mutable means that you can replace an existing value
structure-mutable means that you can add/remove entries
I cannot get a route to work, really. Do you add :ReactElement after each of your functional components or not?
a value mutation is "safe" during iteration
but a structure mutation is horrifying
@PrashinJeevaganth you might want to consider not reusing the same collection for different things
that is quite... a pain in the butt
@geisterfurz007 not even a simple route?
also... I think I dont use functional components
or I misinterpret
16:39
(I watched a talk on kotlin-react the other day and the dude referred to RBuilder.stuff(){..} as functional component)
ah
no I dont use ReactElement
Hello
div(classes = "ui main container") {
	router {
		switch {
			route (path = "workshop/", render = specificWorkshopView())
		}
	}
}
fun RBuilder.myElement(block: StyledDOMBuilder<DIV>.() -> Unit)
{
	// additional stuff

	styledDiv {
		// additional stuff

		block()
	}
}
^ those are my functional elements
That is what I tried but I get an error that I cannot use route for that.
16:42
so am I right to say to iterate using map.keySet() is "safe", making an iterator with map.keySet().iterator() and then iterating it is a structural mutation, hence horrifying.

And in both cases, if a HashMap is used, the order is undefined
throw new Error("cannot use route for that")
0.o?
Yeah that.
@PrashinJeevaganth keySet is not "safe"
new ArrayList<>(map.keySet()) is safe
because you will be iterating over a copy collection rather than the collection you will be mutating
"None of the following functions can be called with the arguments supplied:
public fun RBuilder.route(path: String, exact: Boolean = ..., strict: Boolean = ..., render: () -> ReactElement?): ReactElement defined in react.router.dom
public fun <T : RProps> RBuilder.route(path: String, exact: Boolean = ..., strict: Boolean = ..., render: (props: RouteResultProps<???>) -> ReactElement?): ReactElement defined in react.router.dom"
specificWorkshopView()
what is dat?
have you tried putting it in a lambda?
route(path = "workshop/") { specificWorkshopView() }
specificWorkshopView()
returns Unit
route(path = "workshop/", render = Unit) is not valid
16:46
"Type mismatch: inferred type is Unit but ReactElement? was expected"
The one you proposed isn't either :D
yes it is
hah?
IntelliJ says no
oh wait, it isnt :)
the one I call are RComponents
(woops, forgot the workshop name)
that is how stuff wørks
I never actually noticed the div and such functions return the element
if you would say return div(classes = "ui grid") { ... } it would probably work too
LAD
LAD
Hey, I was just wondering if any of you know how pinch zoom and pan is implemented.
Because I have been trying to figure it out for 2 weeks and I can't get it working properly
pls dont say you are talking about JavaScript
LAD
LAD
16:56
No, this is in Java
I'm doing it with OpenGLES, but I don't think that matters because it's more about the logic of it
Zoe
Zoe
This still isn't an Android room
LAD
LAD
Yeah, I know, but I'm implementing this with Java, so it should be ok in here...
the problem is that Android Java is not actual Java
Zoe
Zoe
@LAD No, you're not
the same as how GScript isnt JavaScript
LAD
LAD
I am just wondering if you guys know of any tutorial or something because all the SO posts and stuff I have looked at haven't worked
Zoe
Zoe
Preferably before I go on a rant on the reasons why Java != Android Java :]
im sorry, noone here knows how android works
Zoe
Zoe
@Wietlol actschually...
we prefer to not write apps in Jabba
LAD
LAD
16:58
Doesn't Android just add it's own stuff to Java?
@Zoe shhh
Zoe
Zoe
@LAD no
LAD
LAD
So how am I able to code in Android if I just know Java?
Zoe
Zoe
The official story is that the Android SDK != Java JDK, but the reality is that Google blatantly plagiarized components of Java into the Android SDK
@geisterfurz007 hmm... I should have put the : ReactElement on each functional member :)
Zoe
Zoe
16:59
But there are variations
The syntax is Java, but that's where the similarities end
for the way how I use them, it doesnt matter that I dont
Zoe
Zoe
There's no public static void main on Android - there are activities
LAD
LAD
Wow, I would never know the difference
but I see that for some stuff, like the routing, it would matter
Zoe
Zoe
Android relies a lot more on callbacks, and there are classes such as Service, Activity, BroadcastReceiver, etc.
Java also has no native support for any OpenGL directly; you'll need LWJGL for that
LAD
LAD
17:00
Well, yeah, but the main method is just different implementations and stuff
Zoe
Zoe
Also, the Android SDK doesn't use the full language features: it cherry picks specific components
still... I use RComponents enough to have not noticed this for... quite a while
Zoe
Zoe
Also, Android runs on Dalvik and not the JVM
The Android runtime is extremely different from the JRE
LAD
LAD
I know there are other things like Activities in Android but I make my apps using as little of that stuff as possible
Zoe
Zoe
You also have no -Xmx or -Xms on Android, and no direct memory management
android:largeHeap="true" in the manifest may or may not give you more memory
17:01
@Zoe I fixed my memory issue today
increased Xmx from 750 to 8192 :)
huh, today I was introduced to assert in java. I love using it in python and js, but I had never seen it in java code. Do any of you use it in production?
Zoe
Zoe
that's a lot of ram o-o
I have 32GB
Zoe
Zoe
@towc don't use assert in production
you need -ea for it to work.
@towc asserts are for tests, not production ;)
17:02
I mean, in production code
also, JUnit is better for tests than assert
not for hobby things
oh...
we do use JUnit, but not actual asserts
@Wietlol for testing internal state? Uhm...
for testing
17:04
@Wietlol but you can't do shit with internal state with junit
Zoe
Zoe
@LAD aside the SDKs and runtime being different, the language features are the next part. Android has implemented some stuff the JDK has separately, which alone creates a mess of packages. There's a ton of [com.]?android.* packages with various stuff you don't find in Java
what do you want to do with assert that you dont want to do with JUnit?
which doesn't mean junit is bad, just that it's limited. You should still use a proper testing tool rather than a bunch of asserts, for running tests
Zoe
Zoe
There's also media stuff and rendering
LAD
LAD
If I may ask, what do you guys think the best way to become a great coder is?
Zoe
Zoe
17:04
Practice
LAD
LAD
I know, but I mean is there anything specific?
Zoe
Zoe
@towc I meant that too. Don't. It's extremely flaky compared to manually throwing an exception
@LAD write lots of code
@LAD rename to "Wietlol"
LAD
LAD
Yeah, I know
Did you guys major in CS in college?
17:06
college is overrated
I lectured teachers
LAD
LAD
I was just wondering if you did, how was it, cause I'm just 17
So, I was wondering what you guys think of CS
@LAD currently on the first year of my first uni course at a somewhat prestigious university, and omg are things frustrating because they're arbitrary and just not great. Don't take that as your goal. I'm dropping in a few months because it's just so bad
I think most of us started programming from when we were teenagers
courses are too general
LAD
LAD
Besides from the actual coding they teach in CS, is the other stuff good?
Zoe
Zoe
I haven't started at a university yet :]
17:07
finish highschool, and as soon as you can take a decent job that interests you take it, is my opinion
when you understand the basics and can write some code, you should be able to learn on your own
LAD
LAD
I actually want to start my own company some day
now, if you want to get into academics (which I eventually do), you might want a degree
when you want to learn how to make user interfaces, read stuff like material design
when you want to learn how to make web services, read stuff like spring
when you want to learn how to write good code, write bad code and accept that it is bad
if you want to become a licensed aereonautical engineer, you're still likely going to need a degree
but if you want a job and enjoy the other parts of life, as a programmer, degree is not great
if you're taking a degree and are into tech, consider maths, or something not CS-related
@Zoe how so?
Zoe
Zoe
17:10
@towc It requires a flag for them to work
because its suuck
@Zoe I don't see that as a bad thing
Zoe
Zoe
assert myImportantCondition != null; passes if -ea isn't present, even if it's false
LAD
LAD
Alright, well sorry to bother you guys and thanks for the feedback
@towc you shouldnt need asserts in your actual code
only for tests
if you want to do a runtime check in your actual code, throw an exception
17:12
@Wietlol I see asserts as more of a debugging kinda thing
Zoe
Zoe
Good
and they help with readability, as comments can get outdated or unclear
comments dont get outdated
or you write bad comments
Zoe
Zoe
In that case, use them, but make sure you don't use them for conditions you rely on. That's the fatal mistake you can end up making with assert
I'd use asserts (debugging) ON TOP OF junit (for testing) AND normal exceptions (which are actually useful for program flow, and as an interface for other code)
17:13
what do you want to do with the asserts during debugging?
can you give an example of how you use it?
sure, hold on
at work, I'm writing a "chat" client, which has states that don't need to be checked, but are helpful in other parts of the code, and adding asserts makes sure that I didn't fuck something up when changing something else, and make it clear to the reader what the context for running a certain method is
async def send_msg(self, peer_id, *msg):
   assert self.has_status('IN_ROOM'), 'you are not in a room'
   assert self.room.has_peer(peer_id), 'peer not in room'
   await self.send('ROOM_PEER_MSG', peer_id, assemble_args(*msg))
that isnt Java
the application that uses this library should itself worry about whether the client is in a room or not, or whether the other person is in the same room
but it's good to have an overview
Zoe
Zoe
@towc don't do that xd
this should never happen in production, but also shouldn't be something to worry about in program flow
ok, maybe it's a bad example
nvm the has_peer part
Zoe
Zoe
17:18
that's exactly the way you shouldn't use it
just the status
Zoe
Zoe
It's too unstable for the checks to work properly
@Wietlol So my alternatives are either to add :ReactElement to the routable components or make them class components and use the child function there, correct?
Oh, the troll from the Java room o/
add : ReactElement everywhere (i think)
@Zoe that's the thing, they're not something you care about, it's just debugging
17:19
"this should never happen in production"
but you do care
Zoe
Zoe
@towc If I had conditions like that, I'd care
@Wietlol do I really want that and then have to return the div everywhere?
Zoe
Zoe
Those are conditions that require actual handling, not a faulty assert that may or may not be enabled
I guess so
What is with stuff where I just render multiple components?
17:20
or put another way, there might be a completely different implementation that should have a compatible interface, and it might not use statuses to manage these things
dont render multiple components :)
or put them under a parent
fun RBuilder.workshopsView(filter: String?, searchHandler: (String?) -> Unit) {
	topBar(searchHandler)
	workshopList(filteredWorkshops(filter))
}
but, sure, you could start with only doing it for the routed components
I got that. Would I then return div { that stuff }?
sure
or span
17:21
googles difference
omg @Zoe just noticed you're running for mod
nice
keep in mind, you want to deal with components
you're at least my second choice
not a list of components
or a pair of components
your view should be a component
also... get rid of the question marks
so when in doubt I wrap with a div to make it one, eh?
17:23
I know you are unsure of if filter is a string, but you should be a bit more decisive
:p
Yeah true that :D
Zoe
Zoe
@towc yeah ^^"
@Wietlol Oh now, I member where that came from! It was the thing that didn't have an initial value
18:01
but do you have a null value for your searches?
or your filters?
here, you are saying workshopsView(null, ...) is valid
and searchHandler(null)
 
6 hours later…
23:57
Hello everyone. I have a quick question. If you are developing using netbeans a software that requires generating reports. What is the best approach that you would follow? use jasper reports?
@ukama Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D

« first day (3066 days earlier)      last day (2099 days later) »