Deep immutability assessment

Programmers all over the world are embracing immutability more and more; however, mutation is still a thing, and in all likelihood it will continue being a thing for as long as there will be programmers. In a world where both mutable and immutable objects exist side by side, there is often a need to ascertain that a certain object is of the immutable variety before proceeding to use it for certain purposes. 

For example, when an object is used as a key in a hash map, the object better be immutable, or else the hash code of the key may change, causing the map to severely malfunction. Note that when this happens, it tends to be a bug which is very difficult to troubleshoot.

Unfortunately, immutability assessment is not an easy task. Most don't even consider it, few talk about it, even fewer actually do it. Programmers all over the world are accustomed to using objects in scenarios where immutability is required, but without ascertaining it, essentially praying that the objects be immutable. There exist libraries that will ascertain immutability, but judging by how marginal status these libraries have in the greater technology landscape, they are not being put into much use.

Introducing Bathyscaphe

Bathyscaphe is a very small library aiming to give the Java world another chance at addressing the problem of immutability assessment instead of letting it linger on like a chronic ailment that you really should go see a doctor about, but keep postponing because you have no time for that.


Fixing broken module names in IntellijIdea

Quite often, when I rename a maven module, IntellijIdea gets confused and keeps showing the old module name in the project view.

  • Re-importing maven projects does not help.
  • Clearing the IntellijIdea caches and restarting does not help.
  • Even deleting the .idea directory does not help.

I discovered that this is happening because: 

  • IntellijIdea keeps information about a project outside of the .idea directory
  • IntellijIdea fails to delete that information when you invalidate caches and restart.

The solution I have found to this problem is:

  1. Exit IntellijIdea.
  2. Go to the application data directory of IntellijIdea (on my Windows machine, this currently is %USERPROFILE%\AppData\Local\JetBrains\IdeaIC2021.3)
  3. Delete the `external_build_system` subdirectory
  4. Start IntellijIdea.
  5. Re-import all maven projects.


How to enable natural scrolling for the mouse wheel under Windows

Some time ago and for about a year I used a Mac, which had natural scrolling by default. I decided to resist the urge to immediately configure it to work like Windows, and instead I made it a point to give natural scrolling a try for at least a while before making up my mind as to whether to keep it or lose it. While giving it a try, I was surprised to see that it was very easy for me to adjust to it, despite the fact that I have been using the unnatural Windows scrolling mode for nearly 30 years. (Ever since the mouse wheel became a thing.) I found that natural scrolling was indeed... natural. So, I kept using it, and I became addicted to it. Ever since then, I always have to configure natural scrolling on any Windows machine that I get my hands on before I can start using that machine.

Artwork based on original mouse-15887 by Arkthus from the Noun Project

Windows is so poor that it does not offer any user interface through which a novice user can change the mouse wheel scrolling mode. To do that you have to edit the registry, and the setting you are going to be modifying is a machine setting, so you will be affecting the mouse wheel mode for all users, not just for yourself. This is unbelievably lame, but hey, that's Windows, we are totally used to lame.


Getting AntiVirus software to trust a Windows Application

anti virus

One of our customers tried installing our Windows Application on one of their computers and their antivirus software complained. They in turn complained to us, so we had to find a solution. I am documenting the solution here.

Possible Causes

Antivirus engines may find a certain file suspicious for many different reasons. The most obvious reason is the file containing a byte pattern which has been encountered in some known malware.  Unfortunately, this does not necessarily mean that the file is infected; it may simply be a coincidence. Furthermore, many other checks performed by antivirus engines tend to fall well within the spectrum of paranoia.  It appears that some particularly paranoid antivirus engines will flag an executable as malware simply because it has not been code-signed or strong-name-signed, or because it has undergone obfuscation. Our application checked both of those boxes.  Your mileage may vary.

How to Troubleshoot

The first problem that you are likely to run into when troubleshooting issues of this kind is how to tell whether your application is passing antivirus checks or not. Obviously, the antivirus suite at the company that I work for was not finding anything suspicious with our application, or else we would have certainly noticed; however, a couple of antivirus suites that our client was running were taking issue with it. I did not have access to the antivirus suites that our client had, and even of I could somehow get my hands on them, I would not be able to install them on my machine, because the antivirus suite which had already been installed on my machine by our IT department played god and did not allow me to touch it.

Luckily, there is a website that provides a solution to the problem. It is called virustotal.com, it aggregates a large number of antivirus engines, and it allows you to upload an executable and see what all these engines think of it. It is quite famous in the security community.

Unfortunately, checking an application with virustotal.com is not an exact science, for many reasons. 


Digital Audio Waveform Generation

For various projects of mine I need to be able to synthesize sound, so I decided to take a quick dabble in the realm of Digital Signal Processing. I mean, how hard could it be, right? 

After some fooling around with the Sampled Audio Subsystem of the Java Virtual Machine I was able to hear sinusoidal waveforms of various frequencies from my speakers, and I was starting to think that I am probably almost done, until I tried to play square waveforms. That's when I realized that I had barely scratched the surface. The square waveforms sounded pretty awful at any frequency, and especially at high octaves they sounded like random notes. Triangular waveforms, sawtooth waveforms, really anything except sinusoidal waveforms all suffered from the same problem.

A bit of googling around soon revealed the name of the source of my troubles: aliasing.

A naïvely sampled square wave, exhibiting a bad case of aliasing. Note how some of the peaks and valleys consist of 3 samples, while some consist of only 2 samples.