Blog posts tagged with "java"

  • Mockito#mock causes NoClassDefFoundException in OSGi

    Today I migrated some of our OSGi integration tests in our bnd workspace to the OSGi-Test support. We already used our own wrapper test classes, to deal with services, service availability and configurations. With the great initial work and some support of a good friend, most of our existing features... [more]

  • Upload to maven central with individually versioned bundles

    We recently started uploading our bundles to maven central. To do that a trusted staging repository is needed (in our case sonatype). They perform certain checks, to make sure your artifacts meet the standards (like e.g. jars need to be signed) of maven central. BND can smoothly handle the the... [more]

  • Bits of Java – Episode 27: What’s new in Java? (continued)

    Today we will continue our excursion into some of the newest features of the Java language. In particular, today is time for Pattern Matching for instanceof. This feature was already introduced with Java 14, with the goal of simplifying one of the most common pattern in Java. You have surely... [more]

  • Bits of Java – Episode 26: What's new in Java

    We started this blog series with Java 11. This is the most recent LTS (long-term support) version of Java so far and it was released in September 2018. Since then, however, a lot of other versions have been released, and currently we are at Java 15, so I think it... [more]

  • Bits of Java – Episode 25: Optional in Java

    We will start this new year with an episode dedicated to optionals in Java. What are optionals? Well, we can think of them as the Java way of expressing something that can be there, but that can also not be there: an optional indeed! Suppose you have a method which... [more]

  • Bits of Java – Episode 24: Bounded and Unbounded Generics in Java

    Last week we talked about generics in Java. Today we will remain on this topic and discuss a few more things you can do with them! At the end of the last post, we said that generics are basically just java.lang.Object for the compiler, and that, indeed, after compilation, what... [more]

  • Bits of Java – Episode 23: Generics in Java

    Today we will discuss a bit about the use of generics in Java, which have been part of Java since its version 5. But what exactly are generics? So, when you build a List object, for instance, you would do something like this: List<String> names = new ArrayList<>(); where, in... [more]

  • Bits of Java – Episode 22: Comparator vs Comparable

    Last week we discussed a bit about lambdas expressions and functional interfaces, and we saw that one of the built-in Java functional interfaces is the Comparator. It provides as functional method: int compare(T obj1, T obj2); which allows to compare two objects and returning an int, whose value depends on... [more]

  • Bits of Java – Episode 21: Lambdas Expressions and Functional Interfaces

    This week we are going to discuss about lambdas expressions in Java. They are a way to write code in a more functional way, and they could be quite useful when you need to perform just a simple operation, and you do not want to write a dedicated method just... [more]

  • Bits of Java – Episode 20: Java Exceptions

    This week we will discuss a bit what happens when there is something wrong with your Java application. There are two main groups of things that could go wrong in your code, and we can distinguish them based on, let’s say, how early Java can detect the problem. In this... [more]

  • OSGi in a Nutshell What is OSGi

    Here we are with our first episode of this new series about OSGi. Before entering the details of our use cases, we first need to give a brief definition of what OSGi is, and what it has tried to accomplish over the years. The OSGi Alliance was founded in March... [more]

  • Bits of Java – Episode 19: Java Enumerators

    This week we are going to discuss Java enumerators. What are they? You can think of an enumerator as a way to define some special strings. Suppose, for instance, you want to implement a method that takes as input parameter a color name and returns to you whether this color... [more]

  • Bits of Java – Episode 18: Java Annotations

    This week we will talk about another interesting feature of the Java language, annotations. What are annotations? Well, you can think of them like a convenient way to express meta data of your objects, where, with objects here, I mean not only Java objects, but also methods, fields, and also... [more]

  • Bits of Java – Episode 17: Modules in Java

    This week we will briefly discuss one, relative new, feature of the Java language, which is the Java Platform Module System (JPMS). The JPMS was introduced in Java 9, with the purpose of introducing a new encapsulation level and allowing developers to build their applications in a more modular way.... [more]

  • Bits of Java – Episode 16: Method overriding vs method hiding

    Last week we started looking into the difference between method overriding and method overloading. This episode will cover, instead, the difference between method overriding and method hiding. We will not go into all the technical details of method overriding, since we already discussed them. What’s important to remember from last... [more]

  • Bits of Java – Episode 15: Method overriding vs method overloading

    In this episode we will discuss a bit the difference between method overriding and method overloading. These are two features that Java supports, under certain conditions, and that can be misleading at a first glance. Let’s start with the simpler one (at least for me), method overloading. Method Overloading A... [more]

  • Bits of Java – Episode 14: The static keyword

    In this episode we will discuss the meaning of the static keyword and we will see where it can be used in your code. There are various places in your code when you can use the static keyword. Let’s see them. static fields: when you mark a variable as static... [more]

  • Bits of Java – Episode 13: From Arrays to Lists and vice versa

    In this episode I would like to discuss how to pass from an array to a list and vice versa, and which are the things to keep in mind once the conversion has been done. From *list* to *array*: to pass from a list to an array you can simply... [more]

  • Bits of Java – Episode 12: Wrapper Classes

    In this episode we will talk about the Java wrapper classes for the primitive types. But first, let me share with you some wonderful news: this week I passed the Orcale Java SE11 Programmer I! Writing this blog hepled me a lot to memorize and to clarify the concepts. But... [more]

  • Bits of Java – Episode 11: Compare and Search in Arrays

    This week I would like to talk about two methods of the Arrays class which I was not familiar with, and whose logic can be a bit tricky: Arrays.binarySearch and Arrays.compare. But first, let me briefly review what an array is. An array is a memory section which is reserved... [more]

  • Bits of Java – Episode 10: String Pool

    Today we will discuss about the String Pool. What is it? Well, in the last post we talked about the fact that String are immutable, and that every time you manipulate a String you are actually creating a new object in memory, which is, for sure, not the most efficient... [more]

  • Bits of Java – Episode 9: String vs StringBuilder

    In this post I would like to review the difference between String and StringBuilder. The main difference between the two is that String is immutable, StringBuilder is not! What does immutable mean? Well, it simply means that when you try to manipulate an immutable object what you are actually doing... [more]

  • Bits of Java - Episode 8: Labels in Loops

    This week’s topic will focus on the use of labels in loops. Did you know that you can use labels to identify your loops? I, for sure, did not know that! It’s true that is not very common, because in most of the cases they decrease your code readability, which... [more]

  • Bits of Java – Episode 7: The switch Statement

    This week I will try to describe the switch statement, focusing in particular to which kind of variables are allowed to be used with such statement. This is one of the Java features that changed a lot over the different releases, thus I hope also some of the most experienced... [more]

  • Bits of Java – Episode 6: Logical Operators and their Short-Circuit Version

    Before starting preparing this exam, I had always used the logical operators && and ||, which you all probably are familiar with. For those who are not, both are binary operators, where the two operands are boolean expressions. The first one returns true if and only if both the operands... [more]

  • Bits of Java – Episode 5: Numeric Promotion

    This week we will talk about numeric promotion. With this term we identify the process for which the compiler promotes a numeric type to a different one. As you probably already know, this can happen using casting. On the other hand, there are some cases in which the compiler automatically... [more]

  • Bits of Java – Episode 4: Overflow and Underflow

    This week I would like to talk about what happens when you force a value, which is outside the range of a certain primitive type, to be of that type. That sounded like a tongue-twister, didn’t it? Let me remind a few concepts before. You are probably all familiar with... [more]

  • Bits of Java - Episode 3: Garbage Collection

    In this episode we will talk about one of the features that distinguishes Java from a lot of other programming languages out there: the concept of garbage collection. In other languages, such C for instance, you should take care of disposing objects that you do not need anymore, in order... [more]

  • Bits of Java – Episode 2: The var keyword

    In this episode I would like to talk about the var keyword, which has been introduced in Java 10, and can be used instead of the type under certain conditions. When declaring a variable in Java, we need to specify what type of variable we want, right? int number =... [more]

  • Bits of Java – Episode 1: One-line-source-code

    As anticipated in my last blog, I would like to start a series of posts to share some features of Java 11 I am learning while studying for the Oracle Certification (JavaSE-11 Programmer I). This week we start with the one-line-source-code. As you probably all know, the standard way to... [more]

  • Bits of Java

    It has been almost one year and a half since I arrived at Data In Motion, where I started my career as a software developer. I had some programming experience from my academic background, but I never used Java before. As the majority of the developers do, also at Data... [more]

  • A bit of Queuing Theory

    We want to share a small study we made when trying to optimize the queue policy for a messaging system. We wanted to find an optimal configuration for a messaging system in terms of buffer size, number of threads and queue blocking policy, or at least to get a feeling... [more]

  • subscribe via RSS