This document discusses exceptions and errors in Java. It provides examples of different types of exceptions like ArrayIndexOutOfBoundsException, NullPointerException, and ClassCastException. It explains exception handling using try-catch blocks and the finally block. It also covers multi-catch, try-with-resources, exception propagation, checked vs unchecked exceptions, and creating custom exceptions. The key aspects of exception handling in Java are to not swallow exceptions, use checked exceptions for recoverable conditions, and use runtime exceptions to indicate programming errors.
Static analysis: Around Java in 60 minutesAndrey Karpov
Theory
Code quality (bugs, vulnerabilities)
Methodologies of code protection against defects
Code Review
Static analysis and everything related to it
Tools
Existing tools of static analysis
SonarQube
PVS-Studio for Java what is it?
Several detected examples of code with defects
More about static analysis
Conclusions
Static analysis: Around Java in 60 minutesAndrey Karpov
Theory
Code quality (bugs, vulnerabilities)
Methodologies of code protection against defects
Code Review
Static analysis and everything related to it
Tools
Existing tools of static analysis
SonarQube
PVS-Studio for Java what is it?
Several detected examples of code with defects
More about static analysis
Conclusions
Concurrent Programming in Java provides a brief overview of the following topics:
• Java language support for concurrency
• Concurrency utilities (java.util.concurrent package)
• Java collections for multithreading (java.util package)
• Parallel streams in Java 8.
Try out the examples. Source code here: https://github.com/CodeOpsTech/ConcurrentJava
Functional Thinking - Programming with Lambdas in Java 8Ganesh Samarthyam
Functional programming is on the rise. Almost all major and mainstream languages support functional programming features, including C++, Java, Swift, and Python, and Visual Basic. With Java 8’s lambda functions, Java now supports functional programming. Moving to functional programming can result in significantly better code and productivity gains. However, it requires a paradigm shift: you need to move away from imperative and object-oriented thinking to start thinking functionally. That’s what this workshop will help you achieve: it will help you make your shift towards functional programming. The workshop will introduce lambda functions in Java with examples from Java library itself. Presented in OSI Days 2015 workshop - http://osidays.com/osidays/shifting-to-functional-programming-lambdas-for-java-developers/
This presentation is on advanced debugging using Java bytecodes (presented in Core Java meetup on 1st October in Accion Labs). If you are a Java developer and are interested in knowing advanced debugging techniques or understanding bytecodes, this presentation is for you.
OCJP Samples Questions: Exceptions and assertionsHari kiran G
Are you a Java enthusiast and preparing for Java 8 certification exam (OCP Java SE 8)? Try out this Quiz on Exceptions and Assertions
This quiz has answers with detailed explanation.
Presentation on the new features introduced in JDK 8, presented on the 26.02.2013 in Sofia University in front of students and members of the Bulgarian java user group.
This presentation provides an overview of key topics in Java class design; also covers best practices/tips and quiz questions. Based on our OCP 8 book.
Let us explore Java 8 features and start using it in your day to day work. You will be surprised how Java has evolved to become so different yet easy & powerful. In this presentation, we discuss Java 8 Stream API.
Concurrent Programming in Java provides a brief overview of the following topics:
• Java language support for concurrency
• Concurrency utilities (java.util.concurrent package)
• Java collections for multithreading (java.util package)
• Parallel streams in Java 8.
Try out the examples. Source code here: https://github.com/CodeOpsTech/ConcurrentJava
Functional Thinking - Programming with Lambdas in Java 8Ganesh Samarthyam
Functional programming is on the rise. Almost all major and mainstream languages support functional programming features, including C++, Java, Swift, and Python, and Visual Basic. With Java 8’s lambda functions, Java now supports functional programming. Moving to functional programming can result in significantly better code and productivity gains. However, it requires a paradigm shift: you need to move away from imperative and object-oriented thinking to start thinking functionally. That’s what this workshop will help you achieve: it will help you make your shift towards functional programming. The workshop will introduce lambda functions in Java with examples from Java library itself. Presented in OSI Days 2015 workshop - http://osidays.com/osidays/shifting-to-functional-programming-lambdas-for-java-developers/
This presentation is on advanced debugging using Java bytecodes (presented in Core Java meetup on 1st October in Accion Labs). If you are a Java developer and are interested in knowing advanced debugging techniques or understanding bytecodes, this presentation is for you.
OCJP Samples Questions: Exceptions and assertionsHari kiran G
Are you a Java enthusiast and preparing for Java 8 certification exam (OCP Java SE 8)? Try out this Quiz on Exceptions and Assertions
This quiz has answers with detailed explanation.
Presentation on the new features introduced in JDK 8, presented on the 26.02.2013 in Sofia University in front of students and members of the Bulgarian java user group.
This presentation provides an overview of key topics in Java class design; also covers best practices/tips and quiz questions. Based on our OCP 8 book.
Let us explore Java 8 features and start using it in your day to day work. You will be surprised how Java has evolved to become so different yet easy & powerful. In this presentation, we discuss Java 8 Stream API.
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch
Julien Ponge
This talk introduces part of the Java SE 7 novelties. The fork/join framework aims at making parallel programming simpler, while Project Coin brings a set of subtle yet useful changes to the Java programming language.
http://soft-shake.ch/2011/conference/sessions/java/2011/09/06/java7.html
While most bugs reveal their cause within their stack trace, Java’s OutOfMemoryError is less talkative and therefore regarded as being difficult to debug by a majority of developers. With the right techniques and tools, memory leaks in Java programs can however be tackled like any other programming error. This talks discusses how a JVM stores data, categorizes different types of memory leaks that can occur in a Java program and presents techniques for fixing such errors. Furthermore, we will have a closer look at lambda expressions and their considerable potential of introducing memory leaks when they are used incautiously.
Java - Exceptions. An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore, these exceptions are to be handled.
Clarozon Technologies final year project center in coimbatore The mixtures of dynamic professionals have made CLAROZON TECHNOLOGIES standout from the competition. We have a team dedicated to share and infuse knowledge into Brains. With subject ideas and experts concentrating on their areas of experience, we are transforming in a unique way.
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
Data privacy is one of the most critical issues that businesses face. This presentation shares insights on the principles and best practices for ensuring the resilience and security of your workload.
Drawing on a real-life project from the HR industry, the various challenges will be demonstrated: data protection, self-healing, business continuity, security, and transparency of data processing. This systematized approach allowed to create a secure AWS cloud infrastructure that not only met strict compliance rules but also exceeded the client's expectations.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Modern design is crucial in today's digital environment, and this is especially true for SharePoint intranets. The design of these digital hubs is critical to user engagement and productivity enhancement. They are the cornerstone of internal collaboration and interaction within enterprises.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Hivelance Technology
Cryptocurrency trading bots are computer programs designed to automate buying, selling, and managing cryptocurrency transactions. These bots utilize advanced algorithms and machine learning techniques to analyze market data, identify trading opportunities, and execute trades on behalf of their users. By automating the decision-making process, crypto trading bots can react to market changes faster than human traders
Hivelance, a leading provider of cryptocurrency trading bot development services, stands out as the premier choice for crypto traders and developers. Hivelance boasts a team of seasoned cryptocurrency experts and software engineers who deeply understand the crypto market and the latest trends in automated trading, Hivelance leverages the latest technologies and tools in the industry, including advanced AI and machine learning algorithms, to create highly efficient and adaptable crypto trading bots
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
Why React Native as a Strategic Advantage for Startup Innovation.pdfayushiqss
Do you know that React Native is being increasingly adopted by startups as well as big companies in the mobile app development industry? Big names like Facebook, Instagram, and Pinterest have already integrated this robust open-source framework.
In fact, according to a report by Statista, the number of React Native developers has been steadily increasing over the years, reaching an estimated 1.9 million by the end of 2024. This means that the demand for this framework in the job market has been growing making it a valuable skill.
But what makes React Native so popular for mobile application development? It offers excellent cross-platform capabilities among other benefits. This way, with React Native, developers can write code once and run it on both iOS and Android devices thus saving time and resources leading to shorter development cycles hence faster time-to-market for your app.
Let’s take the example of a startup, which wanted to release their app on both iOS and Android at once. Through the use of React Native they managed to create an app and bring it into the market within a very short period. This helped them gain an advantage over their competitors because they had access to a large user base who were able to generate revenue quickly for them.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
2. Introduction
• Your Name: Manuela Grindei
• Your day job: Software Developer @ Gamesys
• Your last holiday destination: Vienna
3. Agenda
• Examples
• Class Hierarchy
• try-catch-finally blocks
• multi-catch and try-with-resources
• Exception propagation
• Checked vs unchecked exceptions
• Custom exceptions
4. Example 1
What will be the outcome of the following program and why?
int[] a = {1,2,3,4,5};
for (int i = 1; i <= 5 ; i++) {
System.out.println(a[i]);
}
System.out.println(“Finished”);
5. Example 1
What will be the outcome of the following program and why?
int[] a = {1,2,3,4,5};
for (int i = 1; i <= 5 ; i++) {
System.out.println(a[i]);
}
System.out.println(“Finished”);
Exception in thread "main"
java.lang.ArrayIndexOutOfBoundsException: 5
6. Example 2
What will be the outcome of the following program and why?
static String s;
public static void main(String[] args) {
System.out.println(s.length());
}
7. Example 2
What will be the outcome of the following program and why?
static String s;
public static void main(String[] args) {
System.out.println(s.length());
}
Exception in thread "main" java.lang.NullPointerException
8. Example 3
What will be the outcome of the following program and why?
Integer i = 2;
Long l = (Long)(Number) i;
System.out.println(l);
9. Example 3
What will be the outcome of the following program and why?
Integer i = 2;
Long l = (Long)(Number) i;
System.out.println(l);
Exception in thread "main" java.lang.ClassCastException: java.lang.Integer
cannot be cast to java.lang.Long
10. Example 4
Fibonacci Numbers
Fib0 = 1
Fib1 = 1
Fibn = Fibn-1 + Fibn-2
long fib(long i) {
if (i == 0) {
return 1;
}
if (i == 1) {
return 1;
} else {
return fib(i - 1) + fib(i - 2);
}
}
fib(3) = ?
fib(100_000) = ?
11. Example 4
Fibonacci Numbers
Fib0 = 1
Fib1 = 1
Fibn = Fibn-1 + Fibn-2
long fib(long i) {
if (i == 0) {
return 1;
}
if (i == 1) {
return 1;
} else {
return fib(i - 1) + fib(i - 2);
}
}
fib(3) – returns correct answer
fib(100_000) - StackOverflowError
12. Class Hierarchy
serious problems
that a reasonable
application should
not try to catch
Checked
exceptions
Unchecked
exceptions
conditions that a reasonable
application might want to catch
16. Exceptions
• Exceptions are thrown by a program, and may be caught and handled by
another part of the program
• A program can have a normal execution flow and an exception execution
flow
• Java has a predefined set of exceptions and errors that can occur during
execution
• A program can deal with an exception by:
• ignoring it (see first examples)
• handling it where it occurs
• handling it in another place in the program
17. try-catch
try {
//guarded region, i.e. code that might throw exceptions
…
} catch (Exception1 e1) {
//Exception1 handler
…
} catch (Exception2 e2) {
//Exception2 handler
…
}
- If an exception occurs in try block, the control will
get transferred to the appropriate catch handler
- A catch handler shows that we know how to handle
exceptions of that type
- If Exception1 is a subclass of Exception2, its catch
block should come first (start with the most specific
exception)
18. Exception swallowing
Do NOT write catch handlers like this:
catch(Exception e) {}
- program continues processing as if nothing had gone wrong
- the ignored exception may lead the application to an unexpected failure
- code can be hard to debug
- if the exception really needs to be caught, log some information about it!
19. Example
File file = new File("file.txt");
Writer writer = null;
try {
writer = new PrintWriter(file);
writer.write(new BigDecimal("Hello world!").toString());
writer.flush();
writer.close();
} catch(FileNotFoundException e) {
System.out.println("Caught " + e.getClass().getName());
} catch (IOException e) {
System.out.println("Caught IOException: " + e.getMessage());
} catch (NumberFormatException e) {
System.out.println("Caught " + e.getClass().getName());
}
What is wrong with the above code?
22. Finally block
• any try block needs to be followed by at least a catch or finally block
• finally block always gets executed (unless JVM exits while the try/catch is
being executed or the thread executing the try/catch is interrupted or
killed)
• if there is a return statement in the try block, the finally block executes
right after the return statement is encountered, and before the return
executes
• if an exception is thrown, finally block executes immediately after the
corresponding catch block completes
• if there is no exception, finally executes immediately after the try block
• finally is the ideal place to release resources
23. Multi-catch
File file = new File("file.txt");
Writer writer = null;
try {
writer = new PrintWriter(file);
writer.write(new BigDecimal("Hello world!").toString());
writer.flush();
}
catch (NumberFormatException | IOException e) {
//e is final
//the exceptions must be in different inheritance hierarchies
System.out.println("Caught " + e.getClass().getName());
} finally {
if (writer != null)
try {
writer.close();
} catch (IOException e) {
System.out.println("Caught IOException: " + e.getMessage());
}
}
24. try-with-resources
public static void main(String[] args) throws IOException {
File file = new File("file.txt");
try(Writer writer = new PrintWriter(file)) {
writer.write(new BigDecimal("Hello world!").toString());
writer.flush();
}
}
- Code is more concise and readable
- Automatic Resource Management closes the file for us
- The resources are declared in try between () and must implement AutoCloseable
25. throw/throws
• A method can throw a new exception:
throw new Exception();
throw new IllegalArgumentException();
• A method can specify in its declaration that it throws one or more exceptions
void f() throws Exception1, Exception2;
void f() throws Exception1, Exception2{//…}
26. Exception propagation
public static void main(String[] args) {
doStuff();
}
private static void doStuff() {
doMoreStuff();
}
private static void doMoreStuff() {
int x = 5/0;
}
Exception in thread "main" java.lang.ArithmeticException: / by zero
at Exercise.doMoreStuff(Exercise.java:10)
at Exercise.doStuff(Exercise.java:7)
at Exercise.main(Exercise.java:4)
27. Checked vs unchecked exceptions
Checked Exceptions Unchecked Exceptions
Checked by the compiler Unchecked by the compiler
Extend Exception Extend RuntimeException
If a method throws them, they need to be specified in
that method’s declaration
If a method throws them, they can be specified in the
declaration, but it’s not mandatory
They need to either be caught or rethrown explicitly
by a method
No restrictions
Show recoverable conditions Show programming errors
28. Custom Exceptions
• We can create our own business exceptions by extending either
Exception or RuntimeException
• We can use our exceptions just like the standard ones
29. Example - PersonValidator
public class Person {
private String name;
private int age;
public Person() {}
public Person(String name, int age) {
this.name = name;
this.age = age;
}
//getters and setters
}
public class PersonValidationException extends RuntimeException {
public PersonValidationException(String s) {
super(s);
}
}
}
30. Example - PersonValidator
public final class PersonValidator {
public static final int MAX_LENGTH = 60;
private PersonValidator(){}
public static void validate(Person p) {
if (p.getName() == null || p.getName().isEmpty()) {
throw new PersonValidationException("The person must have a name");
}
if (p.getName().length() > MAX_LENGTH) {
throw new PersonValidationException("The name cannot be longer than "
+ MAX_LENGTH + " characters");
}
if (p.getAge() < 18) {
throw new PersonValidationException("The person cannot be underage");
}
}
}
31. Example - PersonValidator
public static void main(String[] args) {
Person validPerson = new Person("John", 25);
PersonValidator.validate(validPerson);
Person personWithInvalidAge = new Person("Tom", 17);
PersonValidator.validate(personWithInvalidAge);
}
32. Benefits of exception handling
• detect errors easily without writing additional code to test return
values
• exception-handling code is clearly separated from exception-
generating code
• the same exception-handling code can deal with several possible
exceptions
• code to handle an exception that may occur in the governed region
needs to be written only once
33. Conclusions
• Do NOT swallow exceptions
• Use checked exceptions for conditions from which the caller can
reasonably be expected to recover
the exceptional condition cannot be prevented by proper use of the API
the programmer using the API can take some useful action once confronted
with the exception
• Use runtime exceptions to indicate programming errors (mostly
precondition violations)
• By convention: errors are reserved for use by the JVM to indicate
resource deficiencies, invariant failures etc. – do NOT subclass Error