Skip to content

Feed aggregator

Oracle JET MOOC - Tips & Tricks (Part 1)

We're really pleased with the level of activity around the Oracle JET MOOC. Monday next week, when the 2nd week starts, we'll close registration, at which point we expect to have around 2,000 participants. The MOOC will run again, for free, in October, after OpenWorld and JavaOne.

We've picked up on some common problems on the Oracle JET forum and have put together some tips and tricks, as well as news and updates, here:

<span id="XinhaEditingPostion"></span>

We expect to release a similar YouTube clip part way through the 2nd and 3rd week of the course.

Categories: Open Source

Towards More Functional Java Using Streams and Lambdas

In the last post I showed how the Java 7 try-with-resources feature reduces boilerplate code, but probably more importantly how it removes errors related to unclosed resources, thereby eliminating an entire class of errors. In this post, the first in an ad-hoc series on Java 8 features, I'll show how the stream API can reduce the lines of code, but also how it can make the code more readable, maintainable, and less error-prone.

The following code is from a simple back-end service that lets us query metadata about messages flowing through various systems. It takes a map of key-value pairs and creates a Lucene query that can be submitted to SOLR to obtain results. It is primarily used by developers to verify behavior in a distributed system, and it does not support very sophisticated queries, since it only ANDs the key-value pairs together to form the query. For example, given a parameter map containing the (key, value) pairs (lastName, Smith) and (firstName, Bob), the method would generate the query "lastName:Smith AND firstName:Bob". As I said, not very sophisticated.

Categories: Communities

Performance Improvements of Java Monitor From JDK 6 to 9

The new JDK™ 9 early access release contains a JDK enhancement proposal JEP 143, Improve Contended Locking, to improve the performance of contended monitors. Monitors are used by the Java synchronized statement to lock access to a code block. If the synchronized block is called by several threads, the monitor becomes contended. This can degrade performance dramatically. So let us look at the performance improvements of contended monitors.

The graphic shows the time of one method call. The lower numbers mean better performance. The test consists of 8 threads accessing a synchronized block, and all threads are accessing the same monitor. You can download the test here. The test was run on an Intel i5 4 core CPU. As we can see, JDK 9 improves the performance of contended monitors. Let us now look at a direct comparison between JDK 8 and 9.

Categories: Communities

This Week in Spring: Spinnaker and Spring Leaders

Welcome to another installation of This Week in Spring! This week I’m in NYC (for the NYC Java SIG), Austin and San Francisco (for the Silicon Valley Spring User Group) talking to customers and doing meetups! We’ve got a lot to cover, as usual, so let’s get to it!

Categories: Communities

Regular Expression to Validate a Comma-Separated List of Email Addresses

Recently I needed to create a regular expression to validate the format of a comma-separated list of email addresses. Just thought I’d share the result in case it is of use to anyone:


Here’s an example of applying the pattern in Java:

Categories: Communities

Access the original calling context in a callback function in TypeScript

AMIS Technology blog - Tue, 08/23/2016 - 18:16

While working on my Ionic 2 application, I made use of the exif.js library (for extracting meta-data from image files). Some of the key functions in this library are called and passed a callback function that is invoked when the image has been analyzed. From this callback function, I wanted to invoke a function (TypeScript method) defined in my class. Inside the callback function however, I did not have access to the calling context. Inside the callback function, this referred to the object passed into the callback function – and not to what this referred at the point of making the call to EXIF:


It took me some wondering, experimenting, mild cursing and browsing to figure out how to resolve this issue. Using some threads on StackOverflow, I worked out a solution. The callback function is produced by a helper method that produces the callback function and in doing so injects context references into it. Any parameters passed into this method are available as context inside the callback function. In this example, a parameter called outerThis of type AddBeadModal – the class this code resides in – is expected. Any elements defined on this class are now accessible inside the callback function, as is demonstrated with the call to convertDegToDec and the reference to the location property.

Code for exifHandleGetData – the helper method that produces the callback function:


When the call is made to EXIF, the result from the call to exifHandleGetData(this) is passed to EFIX as the callback function. This parameter carries references to the calling scope – through the parameter this.

Code for handlePictureSelection – the method that receives an update to an input type=file component and has EXIF process the selected image (and updates an Angular 2 form component subsequently.




This thread on StackOverflow helped me deal with my challenge:

The post Access the original calling context in a callback function in TypeScript appeared first on AMIS Oracle and Java Blog.

Categories: Companies

JVM Dive for Mere Mortals

Java TV - Tue, 08/23/2016 - 16:31
For developers using Java on a daily basis, JVM is a pretty important component – it runs our software. But it is usually treated like a magic box, which takes code in and produces business features. Have you ever thought about what you are missing with such an approach? This talk covers some of the […]
Categories: Blogs

Are You a ''Leading Edge'' Java Developer?

There is clearly some differences on opinions out there and not all of them are positive for the JVM community. What does it mean to be a “leading edge” developer on the JVM. On the JVM, there are many languages like Scala, Kotlin and Clojure to name languages with real forward momentum.

Are All Languages Welcome on the JVM?

So can you program in two (or more) languages at the same time? Comments like this one give me pause.

Categories: Communities

Refactoring Uncommon Design Smells

We started working on design smells many years earlier than when we started writing our book "Refactoring for Software Design Smells" (see I was digging through some of the old documents and remembered that we did not cover many smells, considering them to be "uncommon smells". By "uncommon smells", I mean the ones that we (co-authors of the book) hadn't seen commonly occurring in software projects, and so did not think that they were worth discussing in detail in the book. We toyed with the idea of listing them in an appendix in the book, but dropped that idea because some readers could object the selection of the smells that formed the core of the book; for example, readers may question the choice of smells covered in the book, and may consider some of the smells mentioned as "uncommon smells" as common in their projects!.

Given the fact that it's been a couple of years since the book was published, I thought it would be interesting to see what you think about these smells. So with that, here are some of the smells that did not make it to our book. If this article generates much interest, I can post more smells in future articles!

Categories: Communities

Using the Play Framework to Create a Java Web Application on Top of a .NET Back-End

Java web applications have come a long way since the days of servlets and Java Server Pages (JSPs). There are now many Java web frameworks for a developer to choose from, including Spring MVC, Java Server Faces, Struts, GWT, Play, and Grails.  As with many other emerging technologies, an abundance of choices of web frameworks will lead to developer fatigue, the feeling of being overwhelmed by the need to keep up with the modern development world’s rapidly multiplying set of options. Interoperability tools like JNBridgePro are an ideal way to deal with many kinds of developer fatigue, particularly when the new technologies are based on Java or .NET. With JNBridgePro, you can learn a small piece of a new technology, while bridging back to other parts of your project, which use the old, familiar technology.

For example, let’s say that you’re a .NET developer maintaining an all-.NET web application using ASP.NET as the web framework. If you’re tasked with updating the application to use a modern Java web framework, you can simplify your task and avoid developer fatigue by reimplementing only the front end, while preserving the familiar .NET code in the back end.

Categories: Communities

Functional Default Arguments, Part Two

In part one, we started to look at a new approach to defining default arguments for methods. Here we continue with a few detailed examples. 

Default Arguments and Functional Programming

Let me introduce you to the MaleProgrammer class, which I'll use as an example for the rest of this newsletter:

Categories: Communities

When Web Companies Grow Up They Turn Into Java Shops [Video]

Earlier this month I attended Pivotal’s SpringOne platform conference in Las Vegas.  In case you’re not familiar with it, Spring is a Java Framework “that helps development teams everywhere build simple, portable, fast and flexible JVM-based systems and applications.”

For some of you out there you may be thinking Java is old school and not relevant in in today’s modern world of digital business.  Au contraire mon frere.  James Governor, the D’artagnan of the analyst world,  countered this belief of irrelevance in his SpringOne talk entitled, “When Web Companies grow up, the become Java Shops.”

Categories: Communities

JVM Debugger Memory View for IntelliJ IDEA

Every day we try to find new ways to improve developer experience with IntelliJ IDEA. It may be a bugfix, a performance improvement, or a new feature (usually in this order). Today we’d like to introduce a new plugin called JVM Debugger Memory View.

The plugin extends the built-in debugger with capabilities to explore objects in the JVM heap during a debug session. The Memory View shows you the total number of objects in the heap grouped by their class name.

Categories: Communities

Functional Default Arguments, Part One


Java lacks a built-in way to define default arguments for methods and constructors. Over the years, several approaches have been proposed, each with its pros and cons. The most widely-known one uses method overloading, though varargs, null values, the builder pattern, and even maps have been used as well. Here we propose a new approach based on functional constructs.

Functional Default ArgumentsBackground

Many languages support default arguments for methods and constructors out of the box, i.e. Scala:

Categories: Communities

Plugging Leaky Abstractions

In 2002, Joel Spolsky coined something he called “The Law of Leaky Abstractions.”  In software, an “abstraction” hides complexity of an underlying system from those using the abstraction.  Examples abound, but for a quick understanding, think of an ORM hiding from you the details of database interaction.

The Law of Leaky Abstractions states that “all non-trivial abstractions, to some degree, are leaky.”  “Leaky” indicates that the abstraction fails to adequately hide its internal details.  Imagine, for instance, that while modifying the objects generated by your ORM, you suddenly needed to manage the particulars of some SQL query.  The abstraction leaked, forcing you to understand the details that it was supposed to hide.

Categories: Communities

Using and including a 3rd party JavaScript library in an Ionic 2 and Angular 2 [typescript] application

AMIS Technology blog - Mon, 08/22/2016 - 05:56

While working on a Ionic 2 (and Angular 2) application, I needed to make use of a 3rd party library (exif – – to be exact, a JavaScript library for client side image analysis). This article describes the few steps I learned I had to go through in order to include that library in my application and use it in my [typescript]code. Note: this X-Team blog article showed me the way, after I read many internet resources that did not help.

1. Download the JS library and add it to the www directory of the Ionic 2 application


2. Add a script tag – to load the JavaScript file – in the index.html file in [that same]directory www


3. In every TS file in which you want to use the library, declare a variable of type any and with the name of the function from the 3rd party library – to act as a placeholder for the 3rd party JS library. During compilation, the real 3rd JS library is not visible, so any direct references to it will cause errors unless there is such a placeholder as shown here. Because the 3rd party library is loaded by the index.htm- the main page in the single page application – its functions will always be available (no lazy loading) and the references to the placeholder become references to the real library as a result.

The next figure shows how I did this for the exif library. Its main object is called EXIF, so my placeholder has that name. In the typescript function I can refer to functions that I know exist on  EXIF – and I do not get compilation errors (nor of course do I get code completion or type safety). At runtime the references to EXIF are satisfied because then the exif.js file has been loaded.





Ionic 2 and External Libraries – good overview of including JavaScript libraries that are offered as node  module and for which typesettings are available –

Include JavaScript Libraries in an Ionic 2 TypeScript Project (including JavaScript libraries for which no node module and/or type settings exist) –

The post Using and including a 3rd party JavaScript library in an Ionic 2 and Angular 2 [typescript] application appeared first on AMIS Oracle and Java Blog.

Categories: Companies

The Benefits of Coding Offline: On Encapsulated Codebases and Headspaces

Last weekend I spent an afternoon at a coffee shop with no wifi in order to solve a problem that I thought should have been simple (automatic de-duping) but which had stumped me for weeks. (I was getting false positives in a pattern I couldn't figure out.)

It took me less than an hour to solve the problem. Turns out I had been counting on one number (but really a string) being very unlikely to collide with other numbers for more than a few digits, when in fact that number -- for domain-specific reasons -- was supposed to share lots of n-grams with other numbers. Dead-simple fix, once I figured this out..and felt stupid for not noticing it before.

Categories: Communities

JDK 9 @Deprecated Annotation Enhancements

In the post What Might a New @Deprecated Look Like?, I used the description of JEP 277 ("Enhanced Deprecation") at that time to guide the creation of an enhanced customized @Deprecated annotation. Since that post, however, there have been significant changes made in JEP 277. This post summarizes the changes and the currently planned enhancements to @Deprecated that are slated for JDK 9.

The changes made to JDK-8065614 ("JEP 277: Enhanced Deprecation") on 2016-03-03 18:04 remove the portion of the JEP description that described the proposed @Deprecated enum. The "Alternatives" section of the main JEP 277 page documents why the enum was removed:

Categories: Communities

An Introduction to Working With JAXB

I am in the process of migrating a few modules that are dependent on Apache XMLBeans to JAXB. It has been an exciting and challenging few days. I thought of jotting down a few important things I came across for anyone who might find it useful in the future.

First of all, let us look at setting up the maven plugin for the JAXB code generation. As of the time of writing this post, I came across two maven plugins. I ended up using the first one as I found the configuration to be quite straightforward.

Categories: Communities

Eight Tools Every Java Developer Should Know (and Love)

At Stormpath, we take quality and productivity very seriously. As any good craftsmen already knows, having talent is not enough, you also need the right tools for the job. Engineering isn’t just a science, it’s also an art, so although we undoubtedly have talent (wink wink) at Stormpath, we always look to supplement with the tool that best fits our needs. Our engineers are always eager to share new tools with the rest of the team. And now, with all the other talented Java developers out there!

In this post, I’ll share the tools that our Java SDK team uses for daily tasks, how we use them, and hopefully, share a few tips that will be useful for you.

Categories: Communities