Tag Archives: interview

Solve Google browser font reduction to 12px

The solution of browser font less than 12px

1. Zoom through transform: scale()

<div class="box text1">The font size is 12px</div>
<! -- inside before adding the span tag, because transform:scale scales the width and height of the outer div -->
<div class="box text2">
    <span> The font size is 8px</span> 
</div>
Copy code
.box{
    width: 200px;
    height:100px;
    margin-bottom: 10px; 
    border: 1px solid red ;
}
.text1{
    font-size: 12px;
}
.text2 span{
    display: inline-block;/*transform:scale()这This attribute scales only the elements whose width and height can be defined. */
    font-size: 16px;
    transform: scale(0.5) ;/* font-size: 16*0.5=8px  */
    transform-origin: left top;/* Adjustment of position*/
}

Why interview requires reading the source code

Some people always think that when interviewing to build an aircraft carrier, you need to screw up your work. In the junior interview, you often ask, what is the life cycle of spring and what has been done since it was started, but it doesn’t matter at work. It’s useless and meaningless. Is that really the case?

Here is a small problem that can only be solved by understanding the initial sequence of spring.

Problem description

In the old version, obtaining a certain data XXX depends on a table tb in the database_ XXX, the new version requires to obtain these data by calling service_ B service interface. It’s reasonable to change bservice’s implementation class to interface mode, but after the change, we find that the application can’t be started! Error: DH handshake failed! I didn’t modify other logic, but I couldn’t start it, and the interface I called doesn’t need any encryption verification. As a fresh undergraduate who has been employed for less than two months, how can I solve this situation?

Background

Application introduction
our Java Web application service_ A is dynamic, the page is dynamic, the fields of the entity class are dynamic, the functions of an entity class and the services to be accessed are dynamic. You need to read the XML configuration file at startup to determine what the application looks like and what capabilities it has. The technology stack is SSM. In order to facilitate the natural loading of XML in @ postcut, That is, these XML configuration files are loaded after bean creation.

Requirements and changes
in the new version of the technology stack, we need to switch to spring boot, with some functional changes. Parsing these model configuration files actually depends on a table tb in the database_ XXX, the new version requires to obtain these data by calling service_ B service interface.

Introduction to service invocation
before calling other services remotely, you need to call addressing service first_ X address to obtain the protocol, IP, port and domain information of the target service, and then get the same address as the domain of its own service, and then get a callable instance of the target service according to the specified load balancing algorithm to call. The sensitive interface needs DH handshake and data encryption and decryption.


Problem orientation

I just changed a service method from database to interface, and the error was DH handshake failure. There was no change, which means that there must be something wrong with the interface call. Debugging found that the DH error occurred in the service addressing report, that is, the error occurred before entering the code I wrote, and the service addressing code was provided by the internal framework, Other people are also using the frame. Why didn’t other people respond?

Make a breakpoint in the addressing part of the framework code of idea decompilation, and debug step by step to find that the addressing service is being called_ The IP port of the target host can’t be found in X, but the framework code takes it directly from the cache. If it doesn’t, NPE will be thrown, and it will be thrown as a DH error by the upper layer. It is reasonable to say that there should be IP port information of addressing service in cache. Debug check shows that the cache is empty, size = 0, indicating that it has not been put in. Ctrl Alt F7 looks for a wave to see where the key pair will be put into the cache. It is found that the framework injects a bean: serviceinfolistener, which is executed after listening to the applicationcontextinitializedevent.

At this point, students who have read the spring source code or know what spring did when it started will immediately know what the problem is, because XML parsing is too early, and the dependent service addressing is not initialized at this time, so it cannot be called.


solve

Temporary scheme:
the parsing of XML will be delayed until the listener of the framework is finished.

The following scheme:
discuss with the framework group, the framework will rely on the addressing service_ The configuration time of X’s secret key pair is advanced to the after properties set of initializing bean, that is, the application developed with the framework is allowed to be called remotely at startup.

Summary of common runtimeException exceptions

Common runtimeException summary in development or interview

The common types are as follows:

 

NullPointerException – null pointer reference exception
ClassCastException – type cast exception.
Illegalargumentexception – pass illegal parameter exception.
Arithmeticexception – arithmetic operation exception
arraystoreexception – storing objects incompatible with declared types into an array exception
indexoutofboundsexception – subscript out of bounds exception
negativearraysizeexception – creating an array with negative size error exception
numberformatexception – number format exception
SecurityException – Security Exception
exception Unsupported operationexception – unsupported operation exception

 

Arithmetic exception class: arithmeticexception
null pointer exception class: NullPointerException
type coercion exception: ClassCastException
array negative subscript exception: negativearrayexception
array subscript out of bounds exception: ArrayIndexOutOfBoundsException
security violation exception: SecurityException
file ended exception: eofexception
exception File not found exception: FileNotFoundException
string converted to number exception: numberformatexception
operation database exception: sqlexception
input/output exception: IOException
method not found exception: nosuchmethodexception

Java.lang.AbstractMethodError
Abstract method error. Thrown when an application attempts to call an abstract method.

java.lang.AssertionError
Wrong assertion. Used to indicate the failure of an assertion.

java.lang.ClassCircularityError
Class loop dependency error. When initializing a class, if a circular dependency between classes is detected, the exception is thrown.

java.lang.ClassFormatError
Class format error. Thrown when the Java virtual machine attempts to read a Java class from a file and detects that the contents of the file do not conform to the valid format of the class.

java.lang.Error
Wrong. Is the base class for all errors and is used to identify serious program running problems. These problems usually describe anomalies that should not be captured by the application.

java.lang.ExceptionInInitializerError
Initializer error. Thrown when an exception occurs during the execution of a class’s static initializer. Static initializers are static statements directly contained in classes.

java.lang.IllegalAccessError
Illegal access error. When an application attempts to access, modify the field of a class or call its method, but violates the visibility declaration of the field or method, it throws the exception.

java.lang.IncompatibleClassChangeError
Incompatible class change error. This exception is thrown when the class definition on which the executing method depends is changed incomparably. Generally, it is easy to cause this error when the declaration definition of some classes in the application is modified without recompiling the whole application.

java.lang.InstantiationError
Instantiation error. This exception is thrown when an application attempts to construct an abstract class or interface through Java’s new operator.

this exception is thrown java.lang.InternalError
Internal error. Used to indicate that an internal error has occurred in the Java virtual machine.

java.lang.LinkageError
Link error. This error and all its subclasses indicate that a class depends on other classes. After the class is compiled, the dependent class changes its class definition and does not recompile all the classes, thus causing an error.

java.lang.NoClassDefFoundError
Class definition error not found. This error is thrown when a Java virtual machine or class loader attempts to instantiate a class and cannot find its definition.

java.lang.NoSuchFieldError
There are no errors in the domain. This error is thrown when an application attempts to access or modify a domain of a class, but there is no definition of the domain in the definition of the class.

java.lang.NoSuchMethodError
Method has no errors. This error is thrown when an application attempts to call a method of a class and there is no definition of the method in the definition of the class.

java.lang.OutOfMemoryError
Out of memory error. This error is thrown when the available memory is insufficient for the Java virtual machine to allocate to an object.

java.lang.StackOverflowError
Stack overflow error. This error is thrown when the level of an application recursive call is too deep to cause a stack overflow.

java.lang.ThreadDeath
The thread ends. This error is thrown when the stop method of the thread class is called to indicate the end of the thread.

java.lang.UnknownError
Unknown error. Used to indicate that an unknown fatal error has occurred in the Java virtual machine.

java.lang.UnsatisfiedLinkError
Unsatisfied link error. Thrown when the Java virtual machine does not find a native language definition of a class declared as a native method.

java.lang.UnsupportedClassVersionError
Unsupported class version error. When the Java virtual machine attempts to read a class file from, but finds that the major and minor version numbers of the file are not supported by the current Java virtual machine, this error is thrown.

java.lang.VerifyError
Validation error. This error is thrown when the verifier detects an internal incompatibility or security problem in a class file.

java.lang.VirtualMachineError
Virtual machine error. It is used to indicate that the virtual machine is damaged or insufficient resources are needed to continue the operation.

java.lang.ArithmeticException
The arithmetic condition is abnormal. For example: integer divided by zero and so on.

java.lang.ArrayIndexOutOfBoundsException
Array index out of bounds exception. Thrown when the index value to the array is negative or greater than or equal to the size of the array.

java.lang.ArrayStoreException
Array storage exception. Thrown when a non array declaration type object is placed in an array.

java.lang.ClassCastException
Class shape exception. Suppose that there are classes a and B (a is not the parent or child of B), and O is an instance of a, then this exception will be thrown when o is forced to be constructed as an instance of class B. This exception is often referred to as a cast exception.

java.lang.ClassNotFoundException
Class exception not found. When the application attempts to construct a class according to the class name in the form of a string, and cannot find the class file with the corresponding name after traversing the classpath, it throws this exception.

java.lang.CloneNotSupportedException
Clone exception is not supported. When the Cloneable interface is not implemented or the clone method is not supported, the clone () method will throw this exception.

java.lang.EnumConstantNotPresentException
Enumeration constant has no exception. This exception is thrown when an application attempts to access an enumeration object by name and enumeration type, but the enumeration object does not contain a constant.

java.lang.Exception
Root exception. Describes what the application wants to capture.

java.lang.IllegalAccessException
Illegal access exception. This exception is thrown when an application attempts to create an instance of a class, access its properties, and call its methods through reflection, but it cannot access the definition of class, property, method, or construction method.

java.lang.IllegalMonitorStateException
Illegal monitoring status is abnormal. This exception is thrown when a thread tries to wait for a monitor of an object (o) that it does not own, or notifies other threads to wait for the monitor of the object (o).

java.lang.IllegalStateException
The illegal state is abnormal. When the Java environment and application are not in the legal calling state of a method, and the method is called, the exception is thrown.

java.lang.IllegalThreadStateException
Illegal thread state exception. When a method is called while it is not in legal calling state, an exception is thrown.

java.lang.IndexOutOfBoundsException
Index out of bounds exception. When the index value of accessing a sequence is less than 0 or greater than or equal to the sequence size, the exception is thrown.

java.lang.InstantiationException
Instantiation exception. This exception is thrown when an attempt is made to create an instance of a class that is an abstract class or interface through the newinstance() method.

java.lang.InterruptedException
Aborted exception. When a thread is in a long waiting, sleeping or other pause state, and other threads terminate the thread through the interrupt method of thread, this exception is thrown.

java.lang.NegativeArraySizeException
Negative array size exception. This exception is thrown when an array is created with a negative size value.

java.lang.NoSuchFieldException
Property has no exception. This exception is thrown when accessing a nonexistent property of a class.

java.lang.NoSuchMethodException
Method has no exception. This exception is thrown when a nonexistent method of a class is accessed.

java.lang.NullPointerException
Null pointer exception. This exception is thrown when the application attempts to use null where the object is required. For example: call instance method of null object, access property of null object, calculate length of null object, throw null with throw statement, etc.

java.lang.NumberFormatException
The number format is abnormal. This exception is thrown when an attempt is made to convert a string to a specified numeric type and the string does not meet the format required by the numeric type.

java.lang.RuntimeException
Runtime exception. Is the parent of all exceptions that can be thrown during normal operation of Java virtual machine.

java.lang.SecurityException
Security exception. An exception thrown by the security manager to indicate a security violation.

java.lang.StringIndexOutOfBoundsException
String index out of bounds exception. When the index value is used to access characters in a string and the index value is less than 0 or greater than or equal to the sequence size, the exception is thrown.

java.lang.TypeNotPresentException
There is no exception for the type. This exception is thrown when an application attempts to access a type in a string representation of the type name, but cannot find the type according to the given name. The difference between this exception and classnotfoundexception is that it is an unchecked exception, while classnotfoundexception is a checked exception.

java.lang.UnsupportedOperationException
Unsupported method exception. Exception indicating that the requested method is not supported.