Handling the Unreachable Code Problem - Exception


The multiple catch blocks can generate unreachable code error i.e. if the first catch block contains the Exception class object then the subsequent catch blocks are never executed.  This is known as Unreachable code problem.
Example:
try{
System.out.println(3/0);         //here arithmetic exception has come


System.out.println(“Pls. print me.”);
 

}catch( Exception e){
 

 System.out.println(“Exception 1.”);
 

}
 

catch(ArithmeticException e1){    //here unreachable code problem has come. Compilation error
System.out.println(“Exception e2”);
 

}
 

 }
 

 }

To avoid this, the last catch block in multiple catch blocks must contain the generic class object that is called the Exception class. This exception class being the super class of all the exception classes and is capable of  catching any  types of exception. The generic Exception class can also be used with multiple catch blocks.
 

Example:
 

try{
System.out.println(3/0);    //here arithmetic exception has come
 

System.out.println(“Pls. print me.”);
 

}catch( ArithmeticException e){
 

 System.out.println(“Exception 1.”);
 

}
 

catch(Exception e1){     //OK
 

System.out.println(“Exception e2”);
 

}
 

 }
 

 }

The Finally block- Exception


The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated.

Note: If the JVM exits while the try or catch code is being executed, then the finally block may not execute. Likewise, if the thread executing the try or catch code is interrupted or killed, the finally block may not execute even though the application as a whole continues.

Syntax:
 

try {
 

<code to be monitored for exceptions>
 

} catch (<ExceptionType1> <ObjName>) {
 

<handler if ExceptionType1 occurs>
 

} ...
 

} finally {
 

<code to be executed before the try block ends>
 

}

Multiple Catch- Exception


So far we have seen how to use a single catch block, now we will see how to use more than one catch blocks in a single try block.In Java when we handle the exceptions then we can have multiple catch blocks for a particular try block to handle many different kind of exceptions that may be generated while running the program i.e. you can use more than one catch clause in a single try block however every catch block can handle only one type of exception. this mechanism is necessary when the try block has statement that raise  different type of exceptions.
The syntax for using this clause is given below:-
 

try{
 

}
 

catch(Exception e1){
 

}
 

catch(Exception e2){
 

}
 

when an exception occurs normal execution is suspended. The runtime system proceeds to find a matching catch block that can handle the exception. If first one catch block has not matched then the second one is matched and so on....
 

example:
 

class DivByZero {
public static void main(String args[]) {
 

try{
System.out.println(3/0);    //here arithmetic exception has come
  

System.out.println(“Pls. print me.”);

}catch( ArrayIndexOutOfBoundsException e){
 

 System.out.println(“Exception 1.”); 

}
 

catch(ArithmeticException e1){
 

System.out.println(“Exception e2”);
 

}
 

 }
 

 }
 

explanation:
 

In this example we have used two catch clause catching the exception ArrayIndexOutOfBoundsException and  Arithmetic Exception in which the statements that may raise exception are kept under the try block. When the program is executed, an exception will be raised. Now that time  the first catch block is skipped and the second catch block handles the error.

Nested try Statements- Exception


Nested try Statements
 

Class NestTry {
 

public static void main (String args[]) {
 

try {
 

//….
 

//….
 

try {
 

//…
 

//….
 

}catch (ExceptionType exOb) {
 

//….
 

}
 

}catch (ExceptionType exOb) {
 

//….
 

}
 

}
 

}
 

Each time a try block is entered, the context of that exception is pushed n the stack.
If an inner try statement does not have a catch handler for a particular exception, the stack is unwounded and next try statement’s catch handlers are inspected for a match.
Continues till 1 catch statement succeeds, or until all try statements are exhausted.
If no catch statement matches, then the Java run-time will handle the exception.

Now Apple world's No 1 PC vendor

Apple is out-shipping traditional PC vendors by a wide margin on the back of strong iPad sales, a marketing research firm has found.

 In the fourth quarter, Apple became the leading worldwide client PC vendor by shipping more than 15 million iPads and 5 million Macs, representing 17 percent of the total 120 million client PCs shipped globally in the fourth quarter, according to Canalys
"We're going through the biggest shift the PC industry has seen in 20 years. It's very difficult to grow in the classic PC market when all of the growth is coming from iPads," Steve Brazier, CEO of Canalys,

Catching Exception:try/catch block

A method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. In the block preceded by catch, we put the code that will be executed if and only if an exception of the given type is thrown. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following:

try

{
   //Protected code
}catch(ExceptionName e1)
{
   //Catch block
}
 A catch statement involves declaring the type of exception you are trying to catch. If an exception occurs in protected code, the catch block (or blocks) that follows the try is checked. If the type of exception that occurred is listed in a catch block, the exception is passed to the catch block much as an argument is passed into a method parameter.

Example:

The following is an array is declared with 2 elements. Then the code tries to access the 3rd element of the array which throws an exception.

import java.io.*;

public class ExcepTest{

public static void main(String args[]){
      
     try{
        
        int a[] = new int[2];
         
        System.out.println("Access element three :" + a[3]);
      
     }catch(ArrayIndexOutOfBoundsException e){
        
        System.out.println("Exception thrown  :" + e);
      
     }
    
        System.out.println("Out of the block");

    }

}

This would produce following result:

Exception thrown  :java.lang.ArrayIndexOutOfBoundsException: 3
Out of the block

Exception Hierarchy

All exception classes are subtypes of the java.lang.Exception class. The exception class is a subclass of the Throwable class. Other than the exception class there is another subclass called Error which is derived from the Throwable class.
Errors are not normally trapped form the Java programs. These conditions normally happen in case of severe failures, which are not handled by the java programs. Errors are generated to indicate errors generated by the runtime environment. Example : JVM is out of Memory. Normally programs cannot recover from errors.


What happens when an exception occurs?

When an error occurs within a method, the method creates an object and hands it off to the runtime system. The object, called an exception object, contains information about the error, including its type and the state of the program when the error occurred. Creating an exception object and handing it to the runtime system is called throwing an exception.
After a method throws an exception, the runtime system attempts to find something to handle it. The set of possible "somethings" to handle the exception is the ordered list of methods that had been called to get to the method where the error occurred. The list of methods is known as the call stack (see the next figure).


                                                     The call stack 
The runtime system searches the call stack for a method that contains a block of code that can handle the exception. This block of code is called an exception handler. The search begins with the method in which the error occurred and proceeds through the call stack in the reverse order in which the methods were called. When an appropriate handler is found, the runtime system passes the exception to the handler. An exception handler is considered appropriate if the type of the exception object thrown matches the type that can be handled by the handler.
The exception handler chosen is said to catch the exception. If the runtime system exhaustively searches all the methods on the call stack without finding an appropriate exception handler, as shown in the next figure, the runtime system (and, consequently, the program) terminates.



                                          Searching the call stack for the exception handler.

What is Exception?

Exceptions in Java are any abnormal, unexpected events or extraordinary conditions that may occur at runtime. They could be file not found exception, unable to get connection exception and so on.
An exception can occur for many different reasons, including the following:
  • A user has entered invalid data.
  • A file that needs to be opened cannot be found.
  • A network connection has been lost in the middle of communications, or the JVM has run out of memory.
Exception Example
 class DivByZero {
 public static void main(String args[]) {
 System.out.println(3/0);
 System.out.println(“Pls. print me.”);
 }
 }
Example: Default Exception
Handling

● Displays this error message
Exception in thread "main"
java.lang.ArithmeticException: / by zero
at DivByZero.main(DivByZero.java:3)

● Default exception handler
– Provided by Java runtime
– Prints out exception description
– Prints the stack trace
 
● Hierarchy of methods where the exception occurred
– Causes the program to terminate
Some of these exceptions are caused by user error, others by programmer error, and others by physical resources that have failed in some manner.
To understand how exception handling works in Java, you need to understand the three categories of exceptions:
  • Checked exceptions: A checked exception is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation. 
  • Runtime exceptions: A runtime exception is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compilation.
  • Errors: These are not exceptions at all, but problems that arise beyond the control of the user or the programmer. Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation.

Facebook becoming publicly

Facebook will begin the process of becoming a publicly-listed company this week, valuing the social networking site at between $75bn (£48bn) and $100bn, reports suggest.


 NEW YORK (AFP) - Facebook may file papers for an initial public offering next week that would value the social network at up to $100 billion, The Wall Street Journal reported Friday.


The newspaper, citing people familiar with the matter, said Facebook could file IPO papers with the US Securities and Exchange Commission (SEC) as early as Wednesday but the "timing is still being discussed."

With a deal size of $10 billion, Facebook would slip into sixth place on the list of largest US IPOs between AT&T Wireless Group ($10.62 billion) and Kraft Foods ($8.68 billion), according to Renaissance Capital.


It would be the largest IPO ever by a US Internet company, eclipsing that of Google in 2004 which raised $1.9 billion and valued the Web search giant at $23 billion.

Facebook chief executive Mark Zuckerberg has deflected IPO talk for years, saying he is focused on building the company and not on going public.

But Zuckerberg, who co-founded Facebook in his Harvard University dorm room nine years ago and has seen it grow to more than 800 million members, recently seemed to bow to the inevitability of selling stock to the public.

Unemployment hits 5 million mark in Spain

Unemployment in Spain passed the five million mark in the last quarter of 2011, official figures show.


The National Statistics Institute said 5.3 million people were out of work at the end of December, up from 4.9 million in the third quarter.

The rate rose from 21.5% in the third quarter to 22.8% - the highest rate in nearly 17 years.

Spain already has the highest jobless rate in the 17-nation eurozone and is expected to slide back into recession.

The 22.8% rate is more than twice the average unemployment rate of the eurozone, which stood at 10.3% in November, according to data released earlier this month.


The Spanish figures show more than half of all 16-24 year-olds in the country are jobless - 51.4% compared with 45.8% before.


Spain's new ruling Popular Party conservative government has pledged labour reforms to try to imporve the jobs market.



Spain has struggled since the property bubble burst in 2008.


In the years between 2004 and 2008, the average house price in Spain rose 44%, Construction represented about 16% of GDP by the end of the boom, and the unemployment rate was down to 7.95%

Create Table in BAAN ERP


1st Method
The purpose of the Create Tables (ttaad4230m000) session is to create tables by company and package.
Menu: BAAN IV Tools / Database Management / Miscellaneous
Session: Create Tables (ttaad4230m000)


2nd Method
Step1: First create domain if you don't want to use exixting domians.
Step2: After creating new domains, convert them to runtime data dictionary and log out the     BAAN
Step3:Now create new tables based on new domains because table structure is dependent on domains.
Step4: Convert them to Runtime Data dictionary and after this log out the BAAN again for saving the changes.
Step5: There is one option in Special in maintain domain and table definition in BAAN tools. Under Special there is one option create table , from where you can create table if you don't want to use 1st Method.

Related Posts:

Maintaining Database Definition

The purpose of the Maintain Database Definitions (ttaad4110m000) session is to define databases, database description types, mirroring specifications, audit trail generation, and whether or not a remote server is utilized.
Menu: BAAN IV Tools / Database Management / Maintenance
Session: Maintain Database Definitions (ttaad4110m000)




Important Fields

  • Database
  • Database Type
  • Audit Trail
Note:
You do not have to run this session very often, since these things are set up at installation. 
Related Posts:

Create Company

The purpose of the Maintain Companies (ttaad1100m000) session is to define company numbers, specify first day of week, default currency and the package combinations to be used by the company.
Menu: BAAN IV Tools / Application Configuration
Session: Maintain Companies (ttaad1100m000)




Database Management in BAAN ERP

Introduction
BAAN applications store data in tables. This data is modified, processed, and printed using several different sessions. BAAN Tools offers tremendous flexibility regarding data storage.


Database Management Procedure


Database Management Overview


BAAN is database and hardware independent. In other words, you can store your data in BAAN Base, Oracle, Informix, and other formats. Moreover, this data can be stored on the machine where BAAN is started or on one or more remote machines on your network. The format and location of data is totally transparent to your application.

Database Management within a Package Combination

Files in the directory structure that give information about the databases are listed:
  • tabledef6.1 What kind of database is used
  • isamdef.1 Where are the Isam tables
  • auditdef6.1 Where are the audit files
  • compnr6.1 A list of shared tables
  • ddOPER The database independent model for this Package Combination
Related Posts

O2 apologised for technical problem

O2 has apologised for a technical problem which caused users' phone numbers to be disclosed when using its mobile data. The company said it normally only passed numbers to "trusted partners". A problem during routine maintenance meant that from 10 January numbers could have been seen by other websites.



"We investigated, identified and fixed it this afternoon. We would like to apologise for the concern we have caused," the company said.

The Information Commissioner's Office had said that it would speak to O2 "to better understand what has happened".

In a blog post the company said: "We are in contact with the Information Commissioner's office, and we will be co-operating fully."

Different Method Using VRC Management


The procedure begins with the creation of a new package combination and new package VRCs.  The developers and their company number are linked to the new package combination.  Runtime help information for the new VRCs are created, and the developer data is modified.  Next, the normal users are linked to the former development package combination.  Their company numbers are also linked to this new package combination.  Finally, the changes in user data are converted to runtime.
The result of this procedure is a new development package combination, which is used by the developers.  The former development package combination has become the new live package combination, which is used by the normal users.




Software components can be exported from one VRC and imported into another.  In this procedure, software components of a certain development VRC are released by exporting them to sequential files.  These files can be imported into a different VRC.  Next, the copied software components are compiled, dumped, or converted to runtime.  Finally, the runtime help of the copied components must be dumped.

Customized software components are normally created in a development environment.  Normal users cannot use these software components, because these users are linked to a package combination, which contains other package VRCs than the development environment.  After testing, the customized components are released for use by normal users.

Package VRC

A Package VRC is a package, which is indicated by a VRC. Within each PVRC, various components can be created and/or modified. The advantages of using PVRCs are:

  • standard software cannot be overwritten
  • new software components can be developed and tested in a protected environment before releasing them to production
  • a PVRC does not contain all software components, only new or changed components
  • development authorizations can be set by PVRC

The software components that can be created and/or modified within PVRCs are:

  • Labels
  • Forms
  • Menus
  • Reports
  • Sessions
  • Functions (Include Files)
  • Program Scripts
  • Messages
  • Questions
  • Domains
  • Table Definitions
  • Dynamic Link Libraries
  • Charts

Package Combination
A Package Combination is a combination of individual PVRCs, but only one VRC from each package.
A working environment is determined by:
  • package combination code
  • various PVRCs
  • company number(s)
  • users
Assigning a Package combination to a user in a company:
Example
This slide depicts two environments: a Production environment (OPER) and a Design Environment (DSGN). The Design Environment is based on the Production Environment because of the derived from structure of the Package VRCs. Everything that is created in the Design Environment will not affect the production environment unless it is released. 


Users are linked to a Package Combination in order to find the software components at runtime. 
Developers will create/modify software components. To be able to run the software components, the developer is linked to a package combination like the user. But in order to create new software components, the developer needs a Current Package VRC.  If authorized, the developer can switch between Package VRCs.


Related Posts:



Version Release Customization(VRC) in BAAN ERP

Introduction
Unlike conventional products, such as cars or furniture, computer software is dynamic in nature. Rapid technological advancement, changing customer requirements, bug fixes, etc., make it imperative for software houses to regularly introduce newer versions of their software. Failure to do so would be disastrous for customers as well as the software house.
However, managing these different versions, their corresponding releases, and all the different customizations performed on them becomes a nightmarish task.


Different kinds of Software

BAAN software is divided into packages. There can be:

  • Standard Software
  • Localizations
  • Line of Business
  • Customizations
  • Own 

The bshell usually searches for a software component from the outside to the inside (see Figure ) .  First, the bshell searches for any own customization for that component.  If there is no own customization, the bshell searches for a customer-specific customization, and so on.  The search path, however, is not the same for all users depending on the package combination to which the user is linked.

Components of a Package VRC

V (Version) - indicates a major change in the software
R (Release) - indicates a minor change or new enhancement
C (Customization) - indicates a customer extension, which uses the customer’s initials

Types of Software:
VRC management can be used to distinguish between various types of software. Baan delivers standard and localization packages. The customer has the option to customize the software to meet their specific needs.
A VRC should be coded using the following legend:
  • L:  Localization
  • B:  Line of business specific
  • C: Customization developed by a third party
  • O:  In-house customization
Rules: When creating a new package VRC that is derived from a standard or localization VRC, you must include one of the letters from the previous legend.
For example:
Existing VRC = tiB40a
New VRC = tiB40Ca cus

Package VRC Deviation Structure

Related Posts:

Google + now allows nicknames



Google has relaxed a requirement that real names be used for making a Google+ profile, allowing people to use nicknames or pseudonyms.



Google said it would also allow maiden names and names in non-Latin scripts.The search giant would, however, ask people to provide proof that they are known by that alternate name.



The proof may include a reference in a news article or a link to a blog with a "meaningful following."
Google+ rival, Facebook, requires real names. Some social networks have been reluctant to permit alternate names, arguing that real names improve trust.

No plans to bring down Facebook on 28 Jan

A Twitter account linked to the hacker group Anonymous denied that the group had released a video calling on the public to launch a cyber-attack on Facebook.

An online war has begun between Anonymous, the people, and the government of the United States," the video narrator says."While SOPA and PIPA may be postponed from Congress, this does not guarantee that our Internet rights will be upheld.

The video called on supporters to download a tool that launches denial of service attacks on targeted websites, and said that if enough people joined the effort, it could bring down Facebook, even though it has over 60,000 servers

Limitations of generics

In this section we will try to find out some of the limitations in use of generics.
  • By this time you must have understood the possible applicability of generics. Generics are used mainly when one object contains other object. It may be a simple class or a collection. You can add restriction on what can be added to other class. It is not possible to add such a restriction in other ways of reusing e.g. inheritance.
  • Generics work on objects and not on primitive data types.
  • When the instances of certain declared classes are injected using Dependency Injection (say using Spring), then you can have partial usage of generics i.e. only the declarations will be made using generics, but actual instantiation depends on if the injection supports generics.
  • Generics reduce the polymorphic nature of code. At compile time only, we finalize the concrete data types to be dealt with, this leaves little opportunity for runtime alteration.

Example comparing the legacy with generic styles

Legacy non-generic example   
// Typical Collections usage before Java 5
List greetings = new ArrayList();
greetings.add("We come in peace.");
greetings.add("Take me to your leader.");
greetings.add("Resistance is futile.");

Iterator it = greetings.iterator();
while (it.hasNext()) {
    String aGreeting = (String)it.next();
    attemptCommunication(aGreeting);
}

Same example using generics
    // Same example using generics.
List<String> greetings = new ArrayList<String>();
greetings.add("We come in peace.");
greetings.add("Take me to your leader.");
greetings.add("Resistance is futile.");

Iterator<String> it = greetings.iterator();
while (it.hasNext()) {
    String aGreeting = it.next();  // No downcast.
    attemptCommunication(aGreeting);
}

Google plans to 'Combine' your user data

Google is planning to rewrite its privacy policy to grant it explicit rights to "combine personal information" across multiple products and services. Previously, it had only implicit rights to do so.

Beginning March 1, the activities and data of a Google user who is signed in will be used to provide a "simpler, more intuitive" experience for users across all the Google services, according to a post on the Official Google blog.

For instance, Google searches may take into consideration context of searches based on the user information and activities, such as knowing that an import car buff would want "Jaguar" the car rather than the big cat of the same name, a video in the post explains. And auto-correct may suggest spellings when a user is typing in Google Docs or Gmail based on prior content they have created.


"It may even be able to tell you when you'll be late for a meeting based on your location, your calendar and local weather conditions," the video says. "All of which means we're not just keeping your private stuff private. We're making it more useful to you in your daily life too."
The changes will roll out along with modifications to the company's privacy policies and terms of service. Google's 60 privacy policies for its different services are being rolled into one uber privacy policy that the company said is designed to be simpler and easier to understand. The terms of service are also being rewritten and consolidated.


In some cases, such as for financial services like Google Wallet, a product may be regulated by industry-specific privacy laws and require detailed descriptions of our practices," the FAQ says. "In others, like Chrome, we simply wanted to explain our privacy practices specific to those products in more detail. In these cases we chose to keep product-specific notices rather than clutter up the main Privacy Policy

Facebook wants ceglia to pick up $84k in leagl fees


Facebook lawyers have asked a judge to order Paul Ceglia to pick up more than $84,000 in legal fees.

Ceglia, the man who claims a contract with CEO Mark Zuckerberg entitles him to a 50 percent stake in the social network, was fined $5,000 earlier this month over delays in making his e-mails available in his case against Facebook. He was also ordered to pay reasonable attorneys' fees.
Facebook also asked Leslie G. Foschio, the federal magistrate for Buffalo, N.Y., to order Ceglia not to file any additional "non-responsive papers or pleadings
 in the case" until he pays the fees.


Ceglia's lawyer, Dean Boland, told the Los Angeles Times that he had not had time to study the filing but indicated he felt the lawyers' rates were excessive. Facebook's chief counsel in the case, Orin Snyder, charged $716.25 an hour, while his most junior associate charged $337.50 an hour, the Times reported.
"If we feel it ought to be modified, we will respond accordingly," Boland told the newspaper. "Cleveland and Buffalo are pretty identical demographically, and I can tell you that no lawyer would survive in the city of Cleveland charging that much an hour because no one would be able to hire him."




Ceglia was ordered to hand over his e-mails account and passwords last August. After he failed to do so, Facebook filed a motion requesting an order compelling him to do so. That hearing also revealed that Ceglia's attorney at the time, Jeffrey Lake, was told by Ceglia that he wouldn't comply with the order.
Lake soon withdrew from the case, becoming the latest in a string of attorneys who stopped representing Ceglia since he initially filed a lawsuit against Facebook and Zuckerberg in 2010. Ceglia claims he and Zuckerberg entered into a contract in 2003 to design and develop the Web site that would ultimately become Facebook--a company now with an estimated value of $100 billion.

Inheritance and Overriding

Classes can extend generic classes, and provide values for type parameters or add new type parameters by in doing so. For example, all the following are legal:
 class MyStringList extends ArrayList<String> { ... }
 class A<X, Y, Z> { ... }
 class B<M,N> extends A<N, String, Integer> { ... }
The addition of generics does, however, change the rules of method overriding slightly. Note in the first example above (MyStringList) the effective signatures of the 'get' method in ArrayList and our subclass:
ArrayList:
 public Object get(int i);
MyStringList:
 public String get(int i);
Through inheritance, the return type has changed. Prior to Java 1.5, this would not have been legal; however, with the addition of parameterized types, the rule has change from "the return types must be identical" to "the return type of the method must be a subtype of all the methods it overrides." As such, the following, which would not compile in a 1.4 environment, is perfectly acceptable in 1.5:
  public class Parent {
    public Number getX() { ... }
  }
  public class Child extends Parent {
    public Integer getX() { ... }
  }

Exception Handling in Generics

Type parameters may be used in the throws clause of a method declaration, but (to preserve JVM compatibility) not in a catch clause. shows an example.

 Generic exception handling.

 public interface MyAction <E extends Exception> {

  public void doWork() throws E;

 }

 public class MyFileAction implements MyAction<FileNotFoundException> {

 public void doWork() throws FileNotFoundException {

   new File("/foo/bar.txt");

  // do something here...

 }

 }

 // client code

 MyFileAction fileAction = new MyFileAction();

  try {

   fileAction.doWork();

  }

  catch (FileNotFoundException e) {

   e.printStackTrace();

  } 

Type Erasure of Generics

When a generic type is instantiated, the compiler translates those types by a technique called type erasure — a process where the compiler removes all information related to type parameters and type arguments within a class or method. Type erasure enables Java applications that use generics to maintain binary compatibility with Java libraries and applications that were created before generics.
For instance, Box<String> is translated to type Box, which is called the raw type — a raw type is a generic class or interface name without any type arguments. This means that you can't find out what type of Object a generic class is using at runtime. The following operations are not possible:
public class MyClass<E> {
    public static void myMethod(Object item) {
        // Compiler error
        if (item instanceof E) {
            ...
        }
        // Compiler error
        E item2 = new E();
        // Compiler error
        E[] iArray = new E[10];
        // Unchecked cast warning
        E obj = (E)new Object();
    }
}
The operations shown in bold are meaningless at runtime because the compiler removes all information about the actual type argument (represented by the type parameter E) at compile time.

40 million people in protest against SOPA and PIPA campaign

In protest against SOPA, Mozilla announced more than 40 million people were reached.around 30 million people in the U.S. use Firefox's default start page, which reached the lion's share of users; and the social media messages Mozilla sent out were retweeted, shared, and liked by more than 20,000 people.As a result of Mozilla's campaign, 360,000 e-mails were sent to senators and members of Congress, 1.8 million people went to mozilla.org/sopa to learn more about the antipiracy laws, and 600,000 went on to visit the Strike Against Censorship page that is hosted by the Electronic Frontier Foundation, Fowler said
Other major Web sites also launched informational and take-action campaigns. Google redirected users to sign a petition being sent to Congress and the Senate that more than 7 million people signed. Wikipedia completely blacked out its English language site and provided information for people to protest SOPA and PIPA.
It's likely that this isn't the last that U.S. legislators will hear from these protesters. "The debate is far from over," Fowler wrote. "Keep the pressure on and make sure your elected officials understand the nuance of the issue and the importance of protecting the open Web."

Device Queue and Print Daemon

Device Queue



All the Print Requests are registered in the Print Queue and printed, for example, directly in UNIX or by using the BAAN lp6.1 script. Some options are:
  • You can restart the print request without running the session again
  • You can preserve the request for later use.
  • You can display the request.
  • You can also change a couple of things depending on the Status of the Print Request. 



Printer Daemon
The Printer Daemon is a process that handles the Queue and registers the request as mentioned before. Without having the Printer Daemon up and running, it is not possible to print, but you can use the Display device.

To start and stop the Printer Daemon, some scripts are used. At system boot time the rc.start script is used to start a couple of processes, one of them is the pdaemon6.1. The rc.stop script is used to stop the processes. But you can also start and stop them by typing:
  • pdaemon6.1 -r Start
  • pdaemon6.1 -k Stop

1) Communication
The Printer Daemon establishes communication with the following processes:

  • lp or other UNIX command
  • lp6.1 
  • filter6.1

The filter6.1 process is used to translate the BAAN internal codes for bold, italic, underlined, and so on, into the printer-specific codes. The filter6.1 process makes use of Printer Interface files which are stored in the ${BSE}/lib/printinf directory. An example is:
${BSE}/lib/printinf/h/hp_lj4

Device Management in BAAN ERP

Introduction
Generating output is one of the most important tasks of an information system.  Raw data is fed into the system and processed.  The processed data must then be sent to a suitable output device such as a printer, a terminal screen, or a file to be of further use.


Figure Representing Device Management:


Device Types:

Within BAAN Software the following Device Types can be defined:
  • Printer (Physical Printer)
  • Direct (also a physical printer but not handled by the print deamon)
  • Logical Printer (set of physical printers)
  • Append to File
  • Rewrite File
  • Screen
  • Aux. Port
1) Screen Device

2) File Devices

There are two different File Devices:

  • Append
  • Rewrite

If required, you can make use of a converting program to convert the output into other formats, for example, ASCII format. 
The user may assign a name and directory path to the output file.

3) Printer Devices
There are three kinds of Printer Devices:

  • Printer
  • Logical Printer
  • Direct

4) The Printer Device Types
A Printer Device is handled by the BAAN shell script lp6.1. This shell script contains the UNIX commands for different kinds of hardware platforms. To define a Printer Device, you have to specify the UNIX Spooler name of that printer, for example pr1001. 
The Logical Printer is group of physical Printers.
The Direct Printer is handled directly by UNIX. You have to specify the whole UNIX command like: /bin/lp -c -dpr1005 -n%d -s %s. See the paragraph on Maintaining Device Data for an explanation of this command. 

5) Device Queue and Printer Daemon
The Device Queue is the Tools Table ttaad320, which contains all the Print Requests. This table is used by the Printer Daemon to register the Requests and to handle them. 

Phone hacking: Jude Law, Lord Prescott and Sara Payne get payouts


 Law's phone was hacked repeatedly between 2003 and 2006

Jude Law and Lord Prescott are among the latest people given payouts over phone hacking by the News of the World.

Actor Law received £130,000 ($200,000) and his ex-wife Sadie Frost £50,000. The ex-deputy PM got £40,000, the High Court was told.


Sara Payne, mother of murdered schoolgirl Sarah, and Shaun Russell, whose wife and daughter were murdered in 1996, were given undisclosed sums.


News International apologised in court but said it would not comment further.


As details emerged of the latest 36 cases, lawyers said most people pursuing damages had now settled out of court.



In a statement issued after the hearing, Law said: "I was suspicious about how information concerning my private life was coming out in the press.


"I changed my phones, I had my house swept for bugs but still the information kept being published. I started to become distrustful of people close to me."


In total 16 articles were published containing Law's personal information. His personal assistant Ben Jackson was also awarded £40,000, while his public relations consultant Ciara Parkes got £35,000.



Law's phone was repeatedly hacked between 2003 and 2006. Frost said she had distrusted him because journalists always knew where she would be, the court heard.

What do you mean by string immutability in Java?

Ques:what is meant by strings are immutable in java?
Ans: immutable means that once an object of that Class has been created it can't be altered.

This is useful as it means you can pass references to the object around, without worrying that someone else is going to change it's contents.

Why String is immutable?
If they were mutable then there would be no String pool implementation and the performance gains of the String pool become lost.

Wrong Use of Generics

When we define generics, we use Object as a data type where we are not sure about the actual type.
Map<String, Object> data = new HashMap<String, Object>();
We are not doing any value add by defining the generic as Object (You must be remembering that Object class is the Super parent class).

Subtyping of Generics

As you already know, it's possible to assign an object of one type to an object of another type provided that the types are compatible. For example, you can assign an Integer to an Object, since Object is one of Integer's supertypes:
Object someObject = new Object();
Integer someInteger = new Integer(10);
someObject = someInteger; // OK
In object-oriented terminology, this is called an "is a" relationship. Since an Integer is a kind of Object, the assignment is allowed. But Integer is also a kind of Number, so the following code is valid as well:
public void someMethod(Number n){
    // method body omitted
}
someMethod(new Integer(10));  // OK
someMethod(new Double(10.1)); // OK
The same is also true with generics. You can perform a generic type invocation, passing Number as its type argument, and any subsequent invocation of add will be allowed if the argument is compatible with Number:
Box<Number> box = new Box<Number>();
box.add(new Integer(10));  // OK
box.add(new Double(10.1)); // OK

What is Wildcard in Generics?

When no specific knowledge of the value of a type parameter is needed, it can be replaced by a wildcard. The wildcard alone, represented by a question mark, takes the value of the default bound of the corresponding formal type parameter, which is Object in following example:
 

void printElements(List<?> myList) { ... }


A wildcard might include an upper bound, which states that the value of the type parameter must be equal to, or a descendent of the bound, as in the following:


 void addAll(Collection<? extends E>) { ... {


A wildcard may alternately specify a lower bound, as in the following:


 void addAll(Collection<? super E>) { ... {


example of upperbound wildcard


It is possible to set the upper bound of the wildcard like this:


List<? extends Vehicle> vehicles = new ArrayList<? extends Vehicle>();   


In this example I have specified the upper bound to be the class Vehicle. I can now define the processElements() method like this:


public void processElements(List<? extends Vehicle> elements){
   for(Vehicle o : elements){
      System.out.println(o);
   }
}


As you can see it is now safe to cast each element in the list to a Vehicle, as it is done by the new for loop inside the method.
Furthermore, it is now safe to call the method using a List<Car> instance, provided that Car extends Vehicle. Here is an example:


List<Car> elements = new ArrayList<Car>
// ... add Car elements to the list.
processElements(elements);


But, even when using a wildcard with an upper bound it is not safe to write to the List. After all, a Car is always a Vehicle, but a Vehicle is not always a Car.

By using wildcard, Well, we got:
1) A way to specify that a collection can contain any type.
2) A way to specify that a collection can contain any subtype of X.
3) ... and this at the price of not being able to write to such a collection.

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More